> another question on this...I have the loop in place, but it still
> prints the entire file to the screen...not the specified number of
> lines...hmmmmph!
>
> $j = 0;
> while ($j < 10) {
> while ( $line = <THATFILE>) {
> print "$line\n";
> $j++;
> }
> }
I usually do something like this:
if(open FILE, "path:to:file") {
my $i = 0;
while(<FILE>) {
chomp;
print "$i $_\n";
last if ++$i == 10;
}
} else {
print "File couldn't be opened: $!\n";
}
Hope that helps.
Regards,
David
- [MacPerl] number 3.5 in my series of beginner problems Christopher Palmer
- Re: [MacPerl] number 3.5 in my series of beginner ... David J. Iberri
- Re: [MacPerl] number 3.5 in my series of beginner ... John Delacour
- Fwd: Re: [MacPerl] number 3.5 in my series of begi... robinmcf
