#!/usr/bin/env perl
use strict;
use warnings;

print "Please enter a directory to open:\n";
chomp (my $dir1 = <STDIN>);

print "Please enter a second directory to open:\n";
chomp (my $dir2 = <STDIN>);

opendir my $dh1, $dir1 or die "Could not open $dir1: $!\n";
my @files1 = readdir($dh1);

opendir my $dh2, $dir2 or die "Could not open $dir2: $!\n";
my @files2 = readdir($dh2);

my $dir_to_open = @files1 > @files2 ? $dir1 : $dir2;
my @files       = @files1 > @files2 ? @files1 : @files2;

print "$dir_to_open has more files.  Please choose one of them: @files\n";
chomp (my $file = <STDIN>);

open my $fh, '<', "$dir_to_open/$file" or die "Cannot open $dir_to_open/$file: $!\n";
chomp(my @lines = <$fh>);

open my $ofh, '>', 'lines.txt' or die "Cannot create lines.txt: $!\n";
my $orig_fh = select $ofh;
print "First line: $lines[0]\n";
print "Last line: $lines[-1]\n";
print "Total lines: " . @lines . "\n";





