So I have gotten to this point with this script...it reads the
current directory, lists the files with a number next to them,
accepts user input as to what file he/she wants to open, but then
does not seem to open the file. I have tried a couple of ways to
print the file to <STDOUT> this just happens to be the last way in
the series.
Any thoughts?
Thanks,
CTP
#!/usr/bin/perl
#script to read contents of current directory, list the files with numbers, and
#ask which we want to open.
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;