I don't know about efficiency, but something like this comes to mind:
my( %hash, @order ); # assume these are initialized # 1 - map my @numbers = map{ exists $hash{ $_ } ? $hash{ $_ } : 999 } @orde +r; # 2 - foreach my @numbers; foreach my $name ( @order ) { push @numbers, ( exists $hash{ $name } ? $hash{ $name } : + 999 ); }
Something like that. Does that work?
In reply to Re: Comparing hashes and arrays
by lestrrat
in thread Comparing hashes and arrays
by Evanovich
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |