in reply to Re: Store log file content from EOF till final occurrence of timestamp
in thread Store log file content from EOF till final occurrence of timestamp
I think the OP wanted all lines before the last instance of the TIMESTAMP match, including non-matching ones.
Better maybe as:
my @log_final; my $watching_for_last_match = 0; # ^ Bonus! This var will give a count of # entries within the timestamp at the end, # compare with scalar(@log_final) for stats while (my $log_line = $log_bckwards->readline) { if ( $watching_for_last_match ) { if ($log_line !~ /$TIMESTAMP/) { last; } } else { if ($log_line =~ /$TIMESTAMP/) { $watching_for_last_match++; } } unshift @log_final, $log_line; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Store log file content from EOF till final occurrence of timestamp
by Athanasius (Cardinal) on Jul 02, 2015 at 13:22 UTC | |
by 1nickt (Canon) on Jul 02, 2015 at 14:00 UTC |