Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: " - " in the syntax

by puudeli (Pilgrim)
on Mar 06, 2009 at 06:04 UTC ( [id://748750]=note: print w/replies, xml ) Need Help??


in reply to Re^2: " - " in the syntax
in thread " - " in the syntax

Did you read Symbolic-Unary-Operators?

$ perl -MO=Deparse -e 'print -"asdf"' print '-asdf'; -e syntax OK
If the operand is an identifier, a string consisting of a minus sign concatenated with the identifier is returned.
$ perl -MO=Deparse -e 'print -"1asdf"' print -1; -e syntax OK
If, however, the string begins with a non-alphabetic character (excluding "+" or "-"), Perl will attempt to convert the string to a numeric and the arithmetic negation is performed.
$ perl -MO=Deparse -e 'print -"-1asdf"' print '+1asdf'; $ perl -MO=Deparse -e 'print -"+1asdf"' print '-1asdf'; -e syntax OK
Otherwise, if the string starts with a plus or minus, a string starting with the opposite sign is returned.
--
seek $her, $from, $everywhere if exists $true{love};

Replies are listed 'Best First'.
Re^4: " - " in the syntax
by Anonymous Monk on Mar 06, 2009 at 09:27 UTC
Re^4: " - " in the syntax
by Anonymous Monk on Mar 06, 2009 at 09:27 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-19 06:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found