I missed this comment before posting my reply below. It would help if you could explain what you intend to use this "last processing occurred at XYZ date/time" for?

I'm actually not sure that you need this concept at all. If you just need the last data for each backup set, then I would process the input file, replacing old info with new as it becomes available. Then the output becomes "hey here is the most recent stuff I have". All of this processing will be so fast that there is no need to keep track of what you did before, just do it all again to keep things simple. I mean there are 86,400 seconds in a day and running a program once per day that takes one second is nothing in the scheme of things!

The problem I came into was that the data for each backup set doesn't appear to be "symmetric". In other words, sometimes some parm values are "missing". This can cause some previous value to continue to be "carried forward" when that is not the right thing to do.

Rather than getting into some "spec war", I post a simple minded use of my previously posted code to report "last values" of each set and then you can tell me: "Hey this would have been right if it had of done X". Below I didn't use $date, don't know why you need $date.

In doing this short thing, I noticed that $param could have a leading space, so I changed a regex.

use strict; use Data::Dumper; my %backups; while (<DATA>) { next if (/^\s*$/); #skip blank lines chomp; my ($date, $backupset , $parm , $value) = parseline($_); if ($value) { $backups{$backupset}{$parm} = $value; } } print Dumper \%backups; sub parseline { my $line = shift; my ($date, $rest) = $line =~ m/(^.*\d{4}):(.*)/; my ($backupset, $msg) = split(/backup:INFO:/, $rest); $backupset =~ s/:\s*$//; #trim some unwanted thing like ':' is ok $backupset =~ s/^\s*backup\.//; #more than one step is just fine! my ($parm, $value) = $msg =~ m/\s*(.*)=\s*(.*)\s*/; $parm ||= $msg; #if match doesn't happen these will be undef $value ||=""; #this trick makes sure that they are defined. return ($date, $backupset, $parm, $value); } =print #some reformatting to try to stop line wrap.... $VAR1 = { 'set1_lvm' => { 'backup-size' => '187.24 GB', 'backup-set' => 'backup.set1_lvm', 'backup-time' => '01:59:04', 'backup-date-epoch' => '1281942003', 'backup-status' => 'Backup succeeded', 'last-backup' => '/home/backups/backup.set1_lvm/20100815000006', 'backup-type' => 'regular', 'backup-date' => '20100816000003' }, 'set2_lvm_lvm' => { 'backup-size' => '424.53 GB', 'backup-time' => '04:33:12', 'backup-status' => 'Backup succeeded', 'last-backup' => '/home/backups/backup.set2_lvm_lvm/20100814200003' }, 'set2_lvm' => { 'backup-directory' => '/home/backups/backup.set2_lvm/20100815200003' +, 'backup-set' => 'backup.set2_lvm', 'backup-date-epoch' => '1281927603', 'backup-type' => 'regular', 'backup-date' => '20100815200003' } }; =cut __DATA__ Sun Aug 15 20:00:03 2010: backup.set2_lvm:backup:INFO: START OF BACKUP Sun Aug 15 20:00:04 2010: backup.set2_lvm:backup:INFO: backup-set=back +up.set2_lvm Sun Aug 15 20:00:04 2010: backup.set2_lvm:backup:INFO: backup-date=201 +00815200003 ..... use __DATA__ segment from my previous post

In reply to Re^3: Parsing logs and bookmarking last line parsed by Marshall
in thread Parsing logs and bookmarking last line parsed by JaeDre619

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.