On Tue, 2008-09-09 at 12:23 -0700, [EMAIL PROTECTED] wrote:
> Hi All,
> 
> i want get the time specified in last line of the file.
> For eg:
> $tail -2 test.log
> 2008 aug 25 14:48:42.800 Sending ping message;
> 2008 aug 25 14:48:43.390 Sending ping message;
> The file size is huge, so i dont want to read the entire file to get
> the last line. Is there any way to get the last line of a file
> directly in perl? i need to get the hour(14) and min(48) specified in
> the last line of the file. can anybody help me on this?
> 
> Thanks in advance!!!!
> 
> 

You can use seek to position the file handle near the end of the file.
Make sure to back it up enough from the end of the file to get more than
one line.  Then read lines, preserving the last.

See `perldoc -f seek`


-- 
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