Bryan R Harris wrote:
John W. Krahn wrote:
Bryan R Harris wrote:
"print+(eval)[-1]"??? What's the "+" for? You're amazing, John.
The "+" is so that you don't get a syntax error because "print(eval)"
with "[-1]" after it is nonsensical. BTW, why are you using a list
slice anyway? Won't "print eval" work just as well?
perl -lne 'BEGIN{$\="\n> ";print}s/(-?[\d.]+)/0+$1/eg;print eval'
That explains what it does, but not how it does it. Is there a perldoc that
discusses it?
perldoc perlop
[ SNIP ]
Symbolic Unary Operators
[ SNIP ]
Unary "+" has no effect whatsoever, even on strings. It is
useful syntactically for separating a function name from a
parenthesized expression that would otherwise be interpreted as
the complete list of function arguments. (See examples above
under "Terms and List Operators (Leftward)".)
(As I've mentioned before, I can't hardly find anything in
perldoc without someone pointing me to it, though I am certainly grateful
for all the work people have done on it.) I do remember reading something
by Damian Conway that "+" evaluates to a space outside of mathematical
expressions, or something like that?
John
--
The programmer is fighting against the two most
destructive forces in the universe: entropy and
human stupidity. -- Damian Conway
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/