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

Re: Grab last line and print

by izut (Chaplain)
on Aug 28, 2006 at 10:54 UTC ( #569963=note: print w/replies, xml ) Need Help??


in reply to Grab last line and print

I see no mention to Tie::File. With this module, you can use your file as a Perl array.

use Tie::File; tie @array, 'Tie::File', $filename or die $!; print $array[-1];

But remember: this will open your file in read/write mode, so any modifications you make in array will reflect on file's data. Use this way for read-only access:

use Tie::File; use Fcntl 'O_RDONLY'; tie @array, 'Tie::File', $filename, mode => O_RDONLY or die $!;

Igor 'izut' Sutton
your code, your rules.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2021-02-27 04:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?