Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
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
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 rifling through the Monastery: (12)
As of 2014-12-29 15:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (191 votes), past polls