Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^4: How to compare 3 lists

by shammow (Novice)
on Oct 26, 2012 at 10:52 UTC ( [id://1001044]=note: print w/replies, xml ) Need Help??


in reply to Re^3: How to compare 3 lists
in thread How to compare 3 lists

Should have clarified.. It's a yes to both, all the snaps are identical on all the systems (name, date etc.). I'm just getting to grips with Perl so I'm going to play with the suggestions (it might take me a while though :-) ). Thanks.

Replies are listed 'Best First'.
Re^5: How to compare 3 lists
by grizzley (Chaplain) on Oct 26, 2012 at 11:07 UTC
    So that makes your problem really easy (untested code):
    $isok = 1; for $logname("logfile1", "logfile2", "logfile3") { open FH, $logname ...; @isthisfileok=(0)x 6; while(<FH>) { $isthisfileok[$1]++ if /^snapshot([1-6])/; # last if /^snapshot([7-9]|\d{2,})/; # are snapshots sorted numeri +cally? then you don't have to search whole file if found snapshot7 or + other } close FH; $somesnapshotnotfound = grep $_ == 0, @isthisfileok; $isok = 0 if !$somesnapshotnotfound; last if !$isok; # don't scan another file if already not ok } print "everything ok" if $isok;

      The actual output looks like -

      NAME tank/filesystem@hourly-1348093078_2012.10.24.13.30.03 tank/filesystem@hourly-1348093078_2012.10.24.14.30.01 tank/filesystem@hourly-1348093078_2012.10.24.15.30.03 tank/filesystem@hourly-1348093078_2012.10.24.16.30.01 tank/filesystem@hourly-1348093078_2012.10.24.17.30.02

      They are auto-created every hour and the command outputs them in date order (I can choose earliest or latest first), so using your example I would need to split on the '.' and pick up the date and hour I think

        Ok, then my approach is of no use in your case. Please use roboticus solution. I don't understand now how do you find snapshots 1-6. Are those the first 6 entries on master? So you could think about not scanning whole files, only 6 entries of master and as many from slaves as needed (date check) - in case the files are huge.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-03-28 16:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found