in reply to Confused about unary +
print (...) interpreted as function at /tmp/t86 line 6.
Perl is interpreting the print statement, followed by parentheses, is a call to print with the arguments in parentheses (print("hi there") instead of print "hi there").
This is an ambiguous syntax, which is why it generates a warning.
You can work around it, as you have, by putting something between the print and the parentheses, or by actually using a parenthesized call to print:
print ((split ' ', $name)[-1]);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Confused about unary +
by Not_a_Number (Prior) on Aug 25, 2003 at 21:08 UTC | |
by sgifford (Prior) on Aug 25, 2003 at 21:16 UTC |