Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Answer: How do I copy out the last line written in a file?

by I0 (Priest)
on Nov 17, 2004 at 00:38 UTC ( #408296=categorized answer: print w/replies, xml ) Need Help??

Q&A > files > How do I copy out the last line written in a file? - Answer contributed by I0

use Tie::File:
use Tie::File; sub last_line_of_file { my $file = shift; tie my @array, 'Tie::File', $file or die "read $file - $!"; $array[-1] }

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
[reisinge]: 'push @foo, @bar' is the same as '@foo = (@foo ,@bar)' ?
[shmem]: yes, at least for the result in @foo
[shmem]: but the results of both operations are different.
[shmem]: result := the discarded result (what's leftmost of the statement)

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2017-04-27 11:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (503 votes). Check out past polls.