in reply to Map Function Weirdness

The comment makes no difference here. Would you like to further explain your question, or perhaps show the output that surprised you?

Replies are listed 'Best First'.
Re^2: Map Function Weirdness
by rthawkcom (Novice) on Nov 08, 2011 at 20:07 UTC
    You sure about that?

    I've tried this on more than one flavor of Perl. It is not a bug in Perl. It does make a difference! But I agree, it shouldn't matter.

      Yes, I'm sure. They both appear to do the same thing here on 5.12.3. It's probably different for your versions of perl, I understand that. That's why I encouraged you to indicate what the surprising output was and why it surprised you.

      If you're actually trying to find the maximum of the values of that hash, then you're going about it in a weird way. Some things you could do to improve would be to:

      • don't use map for its side effects when you really want a foreach loop.
      • don't loop over the keys when you're actually investigating the values and don't care about the keys.
      • investigate the documentation for map. It takes a block or an expression, and evaluates them in list context, placing the results in your @out, so be mindful of what it evaluates to.
      • See List::Util
      A reply falls below the community's threshold of quality. You may see it by logging in.