$ perl -we 'print keys %{{}}'
Unmatched right curly bracket at -e line 1, at end of line
syntax error at -e line 1, near "%{{}}"
Execution of -e aborted due to compilation errors.
Oddly,
perl -we 'print keys %{ { } }'
Exits cleanly with no output & no warnings. WTF?
Posted by: brennen at February 10, 2007 11:16 AM...which is the correct behavior. Apparently in the problem case %{{} parses as "the hash named {{}" and the trailing brace is unmatched.
Posted by: Alan at February 16, 2007 03:55 PMperl -we 'print keys %{+{}}'
is also apparently sufficiently unambiguous. I feel like this lives in toke.c, but after about 15 minutes of looking I'm confident I don't know what the hell is going on there.
Posted by: brennen at February 17, 2007 11:53 AMYou see the {+code} trick a lot, like:
sub foo {
my %args = %{+shift};
...
}
What a hack though.
Posted by: alan at February 18, 2007 02:34 PM