Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re^5: How to compare 3 lists

by grizzley (Chaplain)
on Oct 26, 2012 at 11:07 UTC ( #1001048=note: print w/replies, xml ) Need Help??

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

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;

Replies are listed 'Best First'.
Re^6: How to compare 3 lists
by shammow (Novice) on Oct 26, 2012 at 13:13 UTC

    The actual output looks like -

    NAME tank/filesystem@hourly-1348093078_2012. tank/filesystem@hourly-1348093078_2012. tank/filesystem@hourly-1348093078_2012. tank/filesystem@hourly-1348093078_2012. tank/filesystem@hourly-1348093078_2012.

    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.

        Thanks for your time, I'll go ahead with the other solution, and feed back if that would be useful.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1001048]
[Corion]: So, most things are looking good :-D
[Corion]: I should write some more code for my Jekyll clone, but I don't feel like it, so maybe I should just let that linger instead ;)
[karlgoethebier]: "...mein enemy..."
[marto]: it has finally stopped raining!
[Corion]: marto: Heh - we've got the rain here, now. But it's only intermittently, not permanent. But funny that you should complain about rain ;)
[Discipulus]: rain? i dont remember it..
[marto]: and good news all round, Flash will die come 2020!
[Corion]: So who will be the saviour of the universe, then?!

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2017-07-26 10:50 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (390 votes). Check out past polls.