Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Re: Re: map syntax bug-a-boo?

by chipmunk (Parson)
on Dec 01, 2001 at 09:39 UTC ( #128837=note: print w/replies, xml ) Need Help??


in reply to Re: Re: map syntax bug-a-boo?
in thread map syntax bug-a-boo?

Unary minus negates its operand, either adding a minus sign, or switching a minus sign to a plus sign or vice versa. Unary plus, on the other hand, returns its operand completely unchanged. Why is this useful? It can come in handy when dealing with ambiguous syntax.

More examples of unary plus:

print (3-1)*2; # oops! print (...) interpreted as function ... print +(3-1)*2; sub foo { $foo } $h{foo}; # equivalent to $h{'foo'} $h{+foo}; # but maybe you meant $h{foo()}
See perlop for more on this curious operator.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2020-01-26 22:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?