Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Just a quickie about FH:s

by indapa (Monk)
on Dec 12, 2001 at 00:01 UTC ( #131030=note: print w/replies, xml ) Need Help??


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];

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://131030]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2019-12-11 03:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?