in reply to How a for() assignment works

print map {"Value: $hash_ref->{lc $_}\n"} @vars;

Update:Over zealously forgot to consider "if exists". Better solutions offered.

Replies are listed 'Best First'.
Re^2: How a for() assignment works
by ikegami (Patriarch) on Mar 07, 2008 at 06:01 UTC

    You did get rid of the duplication.

    But it no longer prints what the OP wants it to print.
    And it issues warnings.
    And memory usage was needless increased.

    One step forwards, three steps back.

      Guess I got a little carried away and overlooked the important "if exists" requirement. This is the cause of the warnings. Memory increase doesn't seem to be that big a deal but I didn't check this on anything big.

      Thanks for the reminder to look both ways before jumping into traffic.