Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Looking for discussions of "block after or" syntax error (hash vs block)

by LanX (Canon)
on May 01, 2013 at 18:37 UTC ( #1031629=note: print w/ replies, xml ) Need Help??


in reply to Looking for discussions of "block after or" syntax error

> I've always wondered why this isn't allowed to work.

because of the ambiguity of literal hashes and blocks, the parser can't tell what you mean between curlies w/o heuristics. For instance from time to time people are very confused why map doesn't work like they thought.

That's why Perl6 introduces < > for hashes.

You either need to ...

  • put a do in front of your { block },

  • or use a comma as statement separator.

     open(F, "<$somefile") || print("Could not open file\n"), exit 3;

But keep in mind, the if() solution you showed is the most readable for most programmers.

> Does anyone have a link to a discussion of why this is?

e.g. Re: map problem or Re: map syntax error -- weird

Cheers Rolf

( addicted to the Perl Programming Language)


Comment on Re: Looking for discussions of "block after or" syntax error (hash vs block)
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2015-07-30 04:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls