pattar_g has asked for the wisdom of the Perl Monks concerning the following question:
Problem: I need to compare the output of a certain ClearCase MultiSite command from two different sites.
Sample data from local site:
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)
Sample data from remote site:
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)
What I want to do:
These outputs are in a file. I will try my best to explain it with an example.
For the "\AXIS", I need to compare one value in the table between the two outputs.
So first I find out the table belonging to "\AXIS" in both files. Then I select the table belonging to "foax_axis_AXIS_3" from local site and the table belonging to "smsax_AXIS" form the remote site.
Here I look for the line containing "smsax_AXIS" and find that the values are 25773996 and 25744475.
This tells me that my local site has all the info and more form the remote site. If the values ahd ben the reverses, I would know that I was missing information.
Any ideas how I could achieve this comparison??
If the explanation is not clear, I am ready to call and try to explain the situation..
Code I tried:
for(my $i = 0; $i < scalar(@epochList); $i++) { my $line = $epochList[$i]; chomp($line); next if((!$line) || ($line =~ /^;/) || ($line =~ /deleted/)); print $line . "\n" if($debugLevel >= 5); ### if line contains the VOB Tag, read in the following info until + next VOB Tag is reached ### VOB Tag is hash key in this case if($line =~ /^\s*For VOB replica \"(.*)\"\s*/i) { #### create a hash for VOB info, with VOB Tag as key $tmpVOBTag = $1; $vobInfoHashRef = $epochFileHash{$1} ||= {}; print "level 1" . "$_\n"; print "epoch file hash ---" . $epochFileHash{$tmpVOBTag} . "\n +"; next; } # Get the replica name. if($line =~ /^\s*Actual oplog IDs for row \"(.*)\"\s*/i) { # Store the key to the hash as replica_name $tmpReplicaName = $1; my $replicaInfoHashRef = ${$epochFileHash{$tmpVOBTag}}{$1} ||= + {}; print "level 2" . "$_\n"; print "epoch file hash ---" . ${$epochFileHash{$tmpVOBTag}}{$t +mpReplicaName} . "\n"; next; } # Get oplogs rows ##### similar info found previously, but only once ##### create an array #### ${$epochFileHash{$tmpVOBTag}}{$tmpReplicaName} if(ref(${$epochFileHash{$tmpVOBTag}}{$tmpReplicaName}) ne "ARRAY") { my $tmpReplicaInfoVal = ""; print"value is not an array" . "\n" if($debugLevel >= 5); $tmpReplicaInfoVal = ${$epochFileHash{$tmpVOBTag}}{$tmpReplica +Name}; $vobInfoHashRef->{$replicaInfoHashRef} = (()); push(@{$vobInfoHashRef->{$replicaInfoHashRef}}, $tmpReplicaInf +oVal); } ##### already inserted as array, just push new info into array print "value is an array" . "\n" if($debugLevel >= 5); push(@{$vobInfoHashRef->{$replicaInfoHashRef}}, $line); } ##-------------------------------------------------------------------- +------ ### dump out the whole hash onto the screen, debugging purposes only if($debugLevel >= 0) { print "-" x 50 . "\n"; foreach my $key(keys %epochFileHash) { print "$key-->"; if(ref($epochFileHash{$key}) ne "HASH") { print "$epochFileHash{$key}" . "\n"; } else { # print keys %{ $epochFileHash{$key} }; foreach my $compInfo(keys %{ $epochFileHash{$key} }) { print "$compInfo==>"; if(ref($epochFileHash{$key}->{$compInfo}) ne "ARRAY") { print "$compInfo-->$epochFileHash{$key}->{$compInf +o}" . "\n"; } else { print scalar(@{$epochFileHash{$key}->{$compInfo}}) +; foreach my $compInfoVal(@{$epochFileHash{$key}->{$ +compInfo}}) { print "$compInfoVal" . "\n"; } } } } print "-" x 30 . "\n"; } }
Thanks and regards
Sriram
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: nested hash to parse and compare MultiSite data
by GrandFather (Saint) on Nov 05, 2008 at 09:31 UTC | |
by pattar_g (Initiate) on Nov 05, 2008 at 16:13 UTC | |
|
Re: nested hash to parse and compare MultiSite data
by moritz (Cardinal) on Nov 05, 2008 at 08:35 UTC |