I'm not a big fan of the unary plus solution

I agree, I was just keeping the examples in line with what the map docs were saying. Personally in this case I'd prefer map { (...) } ..., since it makes it look obvious that returning a list is intentional. OTOH I also use map {$_=>1} ... very often, but that one doesn't cause any parse trouble.

The map +{...}, ... stuff is also mentioned in the map docs, although I haven't yet seen it used in the wild - personally I'd probably write map { {...} } .... As you can tell I usually prefer map BLOCK LIST over map EXPR, LIST.

... to force an anon hash constructor use +{:
my @hashes = map +{ lc($_) => 1 }, @array # EXPR, so needs # comma at end
to get a list of anonymous hashes each with only one entry apiece.

In reply to Re^3: strange syntax error with map (unary plus) by haukex
in thread strange syntax error with map by rsFalse

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.