in reply to Re: Error with doublequotes in map
in thread Error with doublequotes in map

Yup, it's thinking it's the LIST form with a hashref missing a trailing comma before the empty parens rather than BLOCK. If you parenthesize things it'll behave as well.

$ perl -MO=Deparse,-p -Mstrict -Mwarnings -e 'map{("$_" => 1)} ();' use warnings; use strict 'refs'; map({("$_", 1);} ()); -e syntax OK

Strange and surprising, yes. "Bug", hrmmm . . . I'd say more ambiguous corner of the grammar.

Replies are listed 'Best First'.
Re^3: Error with doublequotes in map
by bart (Canon) on Feb 12, 2007 at 21:05 UTC
    Just for convenient reference:

    The standard ways to help Perl interpret expression (hash ref) vs. block correctly, is like this:

    map +{ "$_" => 1 }, @list # + => expression (hash ref) (+ comma) map {; "$_" => 1 } @list # ; => block (no comma)
Re^3: Error with doublequotes in map
by mreece (Friar) on Feb 12, 2007 at 23:06 UTC
    interestingly enough, if you leave the -p off of Deparse, it gives you
    map {"$_", 1;} ();
    which perl says is a syntax error.