If I understand what you want then the following should help:

use strict; use warnings; my $local = <<'DATA'; For VOB replica "\AXIS": Actual oplog IDs for row "foax_axis_AXIS_3" (@ fors19aa): oid:a660e345.b4dc4bbf.afd1.4f:2e:af:d0:33:74=555770 (foax_axis_ +AXIS_3) oid:7d7aedf3.575b4c9a.aa8d.cb:be:05:68:e1:ab=6694451 (sisl_AXIS) oid:3acebdef.56e143af.84d3.8f:5e:b3:a4:4a:31=25744475 (smsax_AXIS +) oid:3f1b3b0b.519042b4.93a9.ae:64:52:ad:11:26=5 (smsax_axis +_3) For VOB replica "\PROJECTS": Actual oplog IDs for row "fo_mas_PROJECTS" (@ fors19aa): oid:d4e9cd09.dcad4cce.8559.72:19:f4:ee:f8:11=1804833 (fo_mas_PRO +JECTS) oid:ed0b2a97.1d5a4cd4.8b48.86:07:fb:09:68:52=14998 (heitec_mas +_PROJECTS_3) oid:eefd6347.471443ea.814a.d0:da:e8:d4:fd:c7=25557 (keco_PROJE +CTS_2) oid:039b84e2.4f8d4449.9676.ce:37:80:55:4e:ac=7527 (sisl_PROJE +CTS_2) oid:660856b5.68604e0c.81a8.94:6e:f9:ac:54:ef=832 (vplus_mas_ +PROJECTS_2) For VOB replica "\Newcor": Actual oplog IDs for row "newcor_forchheim" (@ fors19ya.ww005.siemens. +net): oid:73e6ca76.f3eb41c9.a34a.ba:13:ba:f2:d7:e1=386 (newcor_for +chheim) oid:6d1fa895.96d94d5a.8f58.d5:7a:a3:06:a4:5f=28524 (newcor_hof +fman_estate) oid:a8d006a2.2f5644bc.bfe4.83:e2:ad:fc:d8:fc=3099634 (newcor_ind +ia) DATA my $remote = <<'DATA'; For VOB replica "\AXIS": Actual oplog IDs for row "smsax_AXIS" (@ hesba08a): oid:a660e345.b4dc4bbf.afd1.4f:2e:af:d0:33:74=555775 (foax_axis_ +AXIS_3) oid:7d7aedf3.575b4c9a.aa8d.cb:be:05:68:e1:ab=6694474 (sisl_AXIS) oid:3acebdef.56e143af.84d3.8f:5e:b3:a4:4a:31=25773996 (smsax_AXIS +) oid:3f1b3b0b.519042b4.93a9.ae:64:52:ad:11:26=5 (smsax_axis +_3) For VOB replica "\PROJECTS": Actual oplog IDs for row "smsax_projects_2" (@ hesba08a): oid:d4e9cd09.dcad4cce.8559.72:19:f4:ee:f8:11=1805193 (fo_mas_PRO +JECTS) oid:ed0b2a97.1d5a4cd4.8b48.86:07:fb:09:68:52=15004 (heitec_mas +_PROJECTS_3) oid:eefd6347.471443ea.814a.d0:da:e8:d4:fd:c7=25569 (keco_PROJE +CTS_2) oid:039b84e2.4f8d4449.9676.ce:37:80:55:4e:ac=7553 (sisl_PROJE +CTS_2) oid:660856b5.68604e0c.81a8.94:6e:f9:ac:54:ef=833 (vplus_mas_ +PROJECTS_2) For VOB replica "\Newcor": Actual oplog IDs for row "newcor_hoffman_estate" (@ hesba07a.ww005.sie +mens.net): oid:73e6ca76.f3eb41c9.a34a.ba:13:ba:f2:d7:e1=388 (newcor_for +chheim) oid:6d1fa895.96d94d5a.8f58.d5:7a:a3:06:a4:5f=28541 (newcor_hof +fman_estate) oid:a8d006a2.2f5644bc.bfe4.83:e2:ad:fc:d8:fc=3099770 (newcor_ind +ia) DATA open my $inFile, '<', \$local; my %localData = load ($inFile); close $inFile; open $inFile, '<', \$remote; my %remoteData = load ($inFile); close $inFile; for my $dir (sort keys %remoteData) { if (! exists $localData{$dir}) { print "Directory $dir exists remotely but not locally\n"; next; } for my $file (sort keys %{$remoteData{$dir}}) { if (! exists $localData{$dir}{$file}) { print "File $file exists in remote directory $dir but not +locally\n"; next; } my $remoteVers = $remoteData{$dir}{$file}{vers}; my $localVers = $localData{$dir}{$file}{vers}; if ($localVers < $remoteVers) { print "Remote file $dir/$file at version $remoteVers is ne +wer than the local file at version $localVers\n"; } } } sub load { my ($inFile) = @_; my %data; local $/ = 'For VOB replica '; while (<$inFile>) { chomp; next unless m!"\\([^"]+)"!; my $dir = $1; my @lines = /(oid\S+\s+\(\S+\))/g; for (@lines) { next unless /oid:([^=]+)=(\d+)\s+\(([^)]+)/; $data{$dir}{$3} = {id => $1, vers => $2}; } } return %data; }

Prints:

Remote file AXIS/foax_axis_AXIS_3 at version 555775 is newer than the +local file at version 555770 Remote file AXIS/sisl_AXIS at version 6694474 is newer than the local +file at version 6694451 Remote file AXIS/smsax_AXIS at version 25773996 is newer than the loca +l file at version 25744475 Remote file Newcor/newcor_forchheim at version 388 is newer than the l +ocal file at version 386 Remote file Newcor/newcor_hoffman_estate at version 28541 is newer tha +n the local file at version 28524 Remote file Newcor/newcor_india at version 3099770 is newer than the l +ocal file at version 3099634 Remote file PROJECTS/fo_mas_PROJECTS at version 1805193 is newer than +the local file at version 1804833 Remote file PROJECTS/heitec_mas_PROJECTS_3 at version 15004 is newer t +han the local file at version 14998 Remote file PROJECTS/keco_PROJECTS_2 at version 25569 is newer than th +e local file at version 25557 Remote file PROJECTS/sisl_PROJECTS_2 at version 7553 is newer than the + local file at version 7527 Remote file PROJECTS/vplus_mas_PROJECTS_2 at version 833 is newer than + the local file at version 832

I don't guarantee my nomenclature matches anything real however. ;)


Perl reduces RSI - it saves typing

In reply to Re: nested hash to parse and compare MultiSite data by GrandFather
in thread nested hash to parse and compare MultiSite data by pattar_g

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.