http://www.perlmonks.org?node_id=1035958


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 );.

Replies are listed 'Best First'.
Re^2: How to read the last updated lines from a log file
by johngg (Canon) 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