in reply to Tuesday Evening Code Quiz

Well the previous answers of @foo{@a}= reverse @a; are simpler code, they still don't make a lot of sense. To make sense of it, you would write:

my %foo= ( a=>3, b=>2, c=>1 ); @foo{values %foo}= keys %foo;
and then the reader of the code would realize which items "go together" and that %foo is a two-way lookup table.

        - tye (but my friends call me "Tye")

Replies are listed 'Best First'.
Re (tilly) 2: Tuesday Evening Code Quiz
by tilly (Archbishop) on Oct 31, 2001 at 02:42 UTC
    However is this answer safe? If %foo (which appears to be global) already had something in it, you have completely messed that up. Plus you changed the scope horribly with your my you couldn't resist.

    The reverse answers may hide intent, but they are less likely to break other hidden behaviour assumptions which something, somewhere, might rely on.

    So while I like your answer better, I would suggest that you note the assumptions you made...