$ perl -wle 'print (-2)**2' print (...) interpreted as function at -e line 1. Useless use of exponentiation (**) in void context at -e line 1. -2
Just like any other function, if the function name is followed by a left paren, it's taken as the start of the argument list. print (-2)**2 is parsed as (print (-2)) ** 2. This is even documented. From perldoc print:
Also be careful not to follow the print keyword with a left parenthesis unless you want the corresponding right parenthesis to termi- nate the arguments to the print--interpose a "+" or put parentheses around all the arguments.
Abigail
In reply to Re: Operator Precedence (unary nagation and exponentiation)
by Abigail-II
in thread Operator Precedence (unary negation and exponentiation)
by Elliott
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |