I have an array
@arr= ("Fruit","Fruit1","Fruit3","Fruit4")
@arr1=("car","car1","car2","car3","car4")
My code is like this
#usr/bin/perl use Data::Dumper qw(Dumper); foreach $x(@arr) { I will do something and i will put something into an array called @v +al for each of the $x $hash{$x}=[@val]; } print Dumper \%hash; foreach $y(@arr1) { I will do something and i will put something into an array called @v +al2 for each of the $y $hash2{$x}=[@val2]; } print Dumper \%hash2; my %result; foreach $key(keys %hash1) { if(!exists $hash{$key}) { $result{$a}=$hash1{$key}; next; } foreach $new(keys %$key) { $result{$key}{$new}=$hash{$key}{$new} if(!exists $hash{$key}{$new} & +& $hash1{$key}{$new}) eq $hash{$key}{$new}); } } print Dumper \%result;
From above code i am not able to find the difference between two hash
I need to find the difference that is if the element is missing or element is extra in %hash1 it should show which element is missing or which element is extra when compared with %hash
It should check for both keys and values of the hash
please kindly help me to solve this i am strucked here
Thanks in advance
In reply to Difference of Hash by Nansh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |