Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Grab last line and print

by izut (Chaplain)
on Aug 28, 2006 at 10:54 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://569963]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-04-26 07:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found