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.
|
|---|
| 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 |