A. Sinan Unur said:
I "typoed" a line and entered:
my $l =- $_[0];
and it seemed to assign $_[0] to $l, and preprend '-' to it. I don't
see the "=-" operator in Camel index. I tried "=+" and it said I had
the "+=" operator backwards.
Are you so lazy that you could not bring yourself to checking the result
of applying the operator?
I think you were a bit hasty this time, Sinan. The post you replied
to seems to me to be perfectly within the guidelines, and it looks
like the OP has in fact done his homework.
You would not have had an accident had you read
perldoc perlop
See Assignment Operators.
The OP mentions the Camel book, which (IIRC) contains that part of
perlop more or less verbatim. However, as he says, it indeed doesn't
contain a "=-" operator. One can't expect it to be immediately
obvious to everyone that the whitespace between assignment and
negation operators may be omitted.
You might've pointed him instead to the Symbolic Unary Operators
section of perlop, which mentions a somewhat obscure feature of the
unary negation operator:
Unary "-" performs arithmetic negation if the operand is numeric.
If the operand is an identifier, a string consisting of a minus sign
concatenated with the identifier is returned. Otherwise, if the
string starts with a plus or minus, a string starting with the
opposite sign is returned. One effect of these rules is that
-bareword is equivalent to "-bareword".
I think this may be what confused him in the first place, since one
wouldn't necessarily expect negating a non-numeric value to yield
anything meaningful (except zero and a warning, perhaps).