
pinky
Novice
Nov 24, 2011, 5:18 AM
Views: 8041
|
|
Compare two hash of arrays in perl
|
|
|
Hi, How do i compare two hash of arrays in perl without using Data::Compare module? Thanks Pinky. Anything wrong with the below code: foreach my $name (keys %hash_array_cur) { @cur_array = @{ $hash_array_cur{$name}}; foreach my $name2 (keys %hash_array_gold) { @gold_array = @{ $hash_array_gold{$name2}}; my $temp = $name2; $temp =~ s/^\s+//g; $temp =~ s/\s+$//g; next if $name !~ /$temp/; my $temp1 = $hash_array_gold{$name2}[0]; $temp1 =~ s/^\s+//g; $temp1 =~ s/\s+$//g; print "golden is for $name : $temp1 \n"; print "generated is for $name : $hash_array_cur{$name}[0] \n"; if ( $hash_array_cur{$name}[0] !~ /$temp1/) { #print "description in golden file is : $temp1 \n"; #print "description in generated file is : $hash_array_cur{$name}[0] \n"; } } }
(This post was edited by pinky on Nov 24, 2011, 5:19 AM)
|