in reply to Tuesday Evening Code Quiz
As far as an easier way to populate the hash, I'd do:@a = ("a", 1, "b", 2, "c", 3); $i = 0; grep($foo{$_} = $a[$#a - $i++], @a); # for each element $_ in @a # set $foo{$_} to the element OPPOSITE $_ in the array # %foo = ( # a => 3, 1 => 'c', b => 2, # 2 => 'b', c => 1, 3 => 'a', # ) print $foo{"c"}, "\n"; # 1
@foo{@a} = reverse @a;
_____________________________________________________
Jeff[japhy]Pinyan:
Perl,
regex,
and perl
hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
|
|---|