Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
This is fine but I'd also like to print the element from array2 which produces the mismatchmy @array1 = qw(a b c e); my @array2 = qw(a b c d); my %hash; for my $key (@array2) { $hash{$key}++; } for my $key (@array1) { print "Fail: $key\n" unless $hash{$key}; }
Any help welcome.for my $key (@array1) { print "Fail: array1 element is $key, array2 element is $hash{$key} +\n" unless $hash{$key}; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Print both elements in a compare
by Furple (Novice) on Nov 01, 2010 at 19:08 UTC | |
by Anonymous Monk on Nov 01, 2010 at 19:16 UTC | |
by Marshall (Canon) on Nov 01, 2010 at 20:07 UTC | |
|
Re: Print both elements in a compare
by Marshall (Canon) on Nov 01, 2010 at 19:53 UTC | |
by Anonymous Monk on Nov 02, 2010 at 08:26 UTC | |
by Marshall (Canon) on Nov 02, 2010 at 11:31 UTC | |
|
Re: Print both elements in a compare
by moritz (Cardinal) on Nov 01, 2010 at 18:51 UTC | |
by Anonymous Monk on Nov 01, 2010 at 19:05 UTC | |
by moritz (Cardinal) on Nov 01, 2010 at 22:19 UTC | |
|
Re: Print both elements in a compare
by eff_i_g (Curate) on Nov 01, 2010 at 19:53 UTC | |
|
Re: Print both elements in a compare
by Anonymous Monk on Nov 01, 2010 at 18:59 UTC |