At 2:31 PM -0800 3/9/01, Nicholas G. Thornton wrote:
>$j = 0
>#you forgot the ;
>until ($j = 10) {
>while ( $line = <THATFILE>);
># should be while($line = <THATFILE>) {
>print "$line\n";
>$j++
># and then you need another } here
>}

I went back and added all the stuff I forgot, but it wouldn't read 
any of the file.  I changed the until to a while statement with a $j 
< 11 and it then worked...anyone know why?

>
>Looking at
>print "$i - " . "$file_name\n";
>why don't you just use
>print "$i - $file_name\n";

simple...because the program has grown organically and I never went 
back to simplify all the little kludges (which I know I should 
probably simplify as I go) that have crept in as I add to it.

Thanks again...I will be in touch with more soon :)
CTP





ps - the whole script as it sits now is as follows:

#!/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] || die "can't open $file_list[$openme]");

#where does the script exit?
print "hey...I got this far 1\n";


$j = 0;
while ($j < 10) {
while ( $line = <THATFILE>) {
print "$line\n";
$j++;
}
}

#where does the script exit?
print "hey...I got this far 2\n";


close (THATFILE);
closedir CURRDIR;

Reply via email to