in reply to Scalar Vs. List context
There's no way other than learning what makes scalar or list context. Start with assignment:
my $calar = ...; # scalar context my @rray = ...; # list context my ($calar) = ...; # list context my @rray = scalar ...; # scalar context
Some operators, such as concatenation and addition, enforce scalar context. Some circumstances, such as an argument list or list interpolation, enforce list context.
Certain circumstances, such as the return value of a subroutine, depend on the calling context -- you can't analyze them at compilation time.
Is there a circumstance you find especially confusing?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Scalar Vs. List context
by biohisham (Priest) on Jul 11, 2009 at 17:10 UTC | |
by jrsimmon (Hermit) on Jul 11, 2009 at 18:53 UTC |