On Wed, 2008-09-17 at 13:55 +0200, Rob Coops wrote:
> my $last_line;
> while( <> ){
>  $last_line = $_;
> }
> 
> Sure... depends on the size of the log, though. Do that for a log that
> is
> say 500MB in size and you are in for quite a wait as it will loop over
> each
> line in the file will it not?
> 

The OP did not specify how big the file was.  Getting the last line of a
file with variable-length records is not easy.  The above code has the
virtue that it is simple.

If the OP posted why he wants the last line, the most appropriate code
may be possible.  For example, I don't think he wants just the last
line, he wants to monitor the log file.  Different requirements may lead
to different code.


-- 
Just my 0.00000002 million dollars worth,
  Shawn

"Where there's duct tape, there's hope."
        Cross Time Cafe

"Perl is the duct tape of the Internet."
        Hassan Schroeder, Sun's first webmaster


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to