Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re2: Best way to read line x from a file

by Hofmator (Curate)
on Mar 30, 2004 at 12:17 UTC ( [id://340933]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use File::Slurp;
    
    my $f = read_file $filename;
    my $line2 = $1
      if ($f =~ m!\A(?:.*\n){@{[$line_no-1]}}(.*)\n!m);
    
  2. or download this
    use Tie::File;
    
    tie my @file, 'Tie::File', $filename
      or die "Couldn't tie '$filename': $!";
    
    my $line2 = $file[9];
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-03-29 06:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found