Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Comma's and blocks

by naikonta (Curate)
on Oct 04, 2007 at 16:46 UTC ( #642705=note: print w/ replies, xml ) Need Help??


in reply to Comma's and blocks

Well, what can I say. The syntax description for map is,

map BLOCK LIST map EXPR,LIST
If you use the block version, {}, then you don't need a comma. You do need a comma if you use the expression version. If you really like the block version, then just take it as a convenience. Further reading of the doc says,
"{" starts both hash references and blocks, so "map { ..." could be either the start of map BLOCK LIST or map EXPR, LIST. Because perl doesn’t look ahead for the closing "}" it has to take a guess at which its dealing with based what it finds just after the "{". Usually it gets it right, but if it doesn’t it won’t realize something is wrong until it gets to the "}" and encounters the missing (or unexpected) comma.

Hope it's clear now why map {/and this/}, @_; won't even compile.


Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!


Comment on Re: Comma's and blocks
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (10)
As of 2015-07-06 18:29 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 (80 votes), past polls