in reply to Re^2: print a determinate line number
in thread print a determinate line number

That would require e.g. seek(), which can be way faster. If the data format allows to use it.

Maybe that's idiom the opener missed (line-by-line reading of input)

while(<>){ # <>: used handle is STDIN print if $.==5; # so $. is that handle's line number }

or do it yourself in say $i

my $file="/etc/hosts"; my $i=0; # let's use 1-based numbers open(FH,"<",$FILE) or die "dying on $FILE"; while(<FH>){ $i++; print "$i: $_" if $i == 5; }