Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: map syntax error -- weird

by LanX (Canon)
on Mar 22, 2013 at 10:54 UTC ( #1024918=note: print w/ replies, xml ) Need Help??


in reply to Re^2: map syntax error -- weird
in thread map syntax error -- weird

> Why does this work? (same result as your proposals)

There is no clear rule to distinguish between code-block and hash-ref!!!

The parser uses DWIM heuristics to guess if it looks more like a hash-ref or not. (Furthermore "w/o look-ahead")

So in complicated cases you need to give hints for what you mean.

This ambiguity should be one reason why Perl6 switched from {} to <> to indicate hashes.

> UPDATE: Guess: Because there is some statement in there that needs to be executed rather than a static string only?

well it's a perfect hash-ref!

DB<112> $hr={ "$_"."=s" => \$opt{$_} } => { "=s" => \undef }

But I think the used heuristic must be quite simple, something like

  (bareword || variable) (comma || fatcomma) (expr)

So "$_"."=s" is already to complex to fit this rule of thumb.

Cheers Rolf

( addicted to the Perl Programming Language)


Comment on Re^3: map syntax error -- weird
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1024918]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2014-09-20 14:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (159 votes), past polls