Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: How can I grab the last 2 lines of a file?

by AppleFritter (Vicar)
on Jul 26, 2014 at 22:05 UTC ( [id://1095184]=note: print w/replies, xml ) Need Help??


in reply to How can I grab the last 2 lines of a file?

Take a look at File::ReadBackwards:

#!/usr/bin/perl use strict; use warnings; use feature qw/say/; use File::ReadBackwards; tie *BW, 'File::ReadBackwards', '/path/to/your_file' or die "Cannot re +ad file: $!"; chomp(my $name = <BW>); chomp(my $id = <BW>); say "Name: $name"; say "ID: $id";

Hope this helps!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-20 02:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found