CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced: Compare two hash of arrays in perl: Edit Log



pinky
Novice

Nov 24, 2011, 5:18 AM


Views: 10001
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)


Edit Log:
Post edited by pinky (Novice) on Nov 24, 2011, 5:19 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives