http://www.perlmonks.org?node_id=131030


in reply to Just a quickie about FH:s

If I understand your question, you want to read/display a particular line in a file. There is a recipie (8.8) for this in the Perl Cookbook
($filename, $line) = @ARGV; open (IN, "$filename" ) or die "can't open $filename: $!\n"; while (<IN>) { $input = $_; last if $. == $line; } if ($. != $line) { die "didn't find line: $line in $filename\n"; } print $input;
If your file isn't too large, read it into an array:
@lines = <FILE>; $desired_line = $lines[$LINE_NUMBER];