Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

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

by chipmunk (Parson)
on Dec 01, 2001 at 09:39 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://128837]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2024-03-28 21:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found