> 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

Reply via email to