in reply to Comparing hashes and arrays
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?
|
|---|