Many thanks for all of your help and suggestions so far.
I have now hit a new sticking point...I want to print the contents of
the user chosen file to the screen 10 lines at a time instead of the
whole thing. Is there an easy way to do this?
I'm guessing I need to replace the 'print while (<THATFILE>);' with a
loop that counts to ten and prints out one line at a time. I tried
this:
$j = 0
until ($j = 10) {
while ( $line = <THATFILE>);
print "$line\n";
$j++
}
but the script no longer compiles...any ideas
Thanks in advance,
CTP
Current script without code above:
#!/usr/bin/perl
opendir ( CURRDIR, '' ) || die "Can't open it!";
@file_list = readdir ( CURRDIR );
$i = 0;
foreach $file_name ( @file_list ) {
print "$i - " . "$file_name\n";
$i ++;
}
print "Which file would you like to open?: ";
chomp ( $openme = <STDIN> );
print "I will open $file_list[$openme]\n";
open (THATFILE , $file_list[$openme]);
print while (<THATFILE>);
close (THATFILE);
closedir CURRDIR;