in reply to Question about list context
It's not a issue of context, but rather of an ambiguous syntax; perl is just making the wrong guess as to what you mean. In your first example, Perl thinks that the parens should be interepreted as a function call, like print("foo"). To help perl out, disambiguate the expression with +, like this:
print +(split "\t", $line)[0], "\n" ;
Update:I posted another example of a similar phenomenon in this recent node.
the lowliest monk
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Question about list context
by rir (Vicar) on Apr 14, 2005 at 16:17 UTC |