Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Perl oddities

by hardburn (Abbot)
on Mar 01, 2005 at 14:27 UTC ( #435446=note: print w/ replies, xml ) Need Help??


in reply to Perl oddities

The fact that a comma after a map block is a syntax error:

$ perl -e 'map { $_ }, qw/foo bar/' syntax error at -e line 1, near "}," Execution of -e aborted due to compilation errors.

I'm fine with it not being required, but it shouldn't yell at you if you happen to include it.

"There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.


Comment on Re: Perl oddities
Download Code
Re^2: Perl oddities
by dragonchild (Archbishop) on Mar 01, 2005 at 14:36 UTC
    And if you're trying to map your inputs into hashrefs with a comma, you can't. :-/

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

        No, you don't need the +:
        print map {"$_",}, qw/foo bar/
        works as well, although you need more characters. I don't think there is any case in Perl where you need unary minus for disambiguation where you can't disambiguate in another way using 2 or 3 other keystrokes.

        Unary plus is just a convenience, not a requirement.

Re^2: Perl oddities
by TimToady (Parson) on Mar 01, 2005 at 20:29 UTC
    The comma after the block is optional in Perl 6. On the other hand, you have to use a block there. The expression form is not supported in Perl 6. Or more precisely, the first arguments will be expected to be an expression that returns a closure to be executed.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (9)
As of 2014-07-31 08:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (246 votes), past polls