Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: How to read the last updated lines from a log file

by frozenwithjoy (Curate)
on May 30, 2013 at 04:41 UTC ( #1035958=note: print w/ replies, xml ) Need Help??


in reply to How to read the last updated lines from a log file

Dear Monks suggest me how i need to parse the log with only last occurrence of of <START>....</START> log content
How about just reading the log file backwards (see How do I read a file line by line in reverse order (from EOF to start of file)) and stopping when you hit the first <START> (i.e., the beginning of the last log file)? You could capture the lines (in reverse order) in your @logcontent array and then reverse the order (to the proper order) with @logcontent = reverse @logcontent before calling sendmail( $now, \@logcontent );.


Comment on Re: How to read the last updated lines from a log file
Select or Download Code
Replies are listed 'Best First'.
Re^2: How to read the last updated lines from a log file
by johngg (Abbot) on May 30, 2013 at 11:46 UTC
    You could capture the lines (in reverse order) in your @logcontent array and then reverse the order (to the proper order) with @logcontent = reverse @logcontent ...

    Store each line read in reverse order by doing an unshift rather than a push onto the @logcontent array then there will be no need for the reverse.

    Cheers,

    JohnGG

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (19)
As of 2015-07-30 20:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (273 votes), past polls