On Wed, 20 Nov 2002 13:33:27 -0600, [EMAIL PROTECTED] (Steven Lembark)
wrote:

> -- Philip Newton <[EMAIL PROTECTED]>
> 
> > On Wed, 20 Nov 2002 10:35:11 -0600, [EMAIL PROTECTED] (Steven Lembark)
> > wrote:
> >
> >> -- Andrew Molyneux <[EMAIL PROTECTED]>
> >>
> >> > I'd probably do:
> >> > my ($max, $sep, $end) = @_;
> >>
> >> Yes, becuase if you did it this way you'd get $end equal
> >> to the integer coult of the number of list arguments passed
> >> plus one for the end value.
> >
> > Huh? $end gets assigned $_[2]. I'm not sure where you get an "integer
> > coult" from.
> 
> Look up what happens to arrays in a scalar context.

There's no scalar context involved as I understand it. Since you have
parentheses, it's a list context assignment.

> Or try in the debugger:
> 
> my ( $a, $b, $c ) = qw( foo bar bletch blort bim bam blort );
> 
> what do yo get for $c?

"bletch". Well, at least if I omit the "my" and do only ($a, $b, $c) =
qw( ... ). Possibly a scoping problem with my debugger: it works when I
type it straight into Perl, without the debugger.

Which version of Perl are you using? qw() used to be implemented using
split(), which pays attention to the number of arguments available for
assignment on the left-hand side (unlike other list assignment). I
believe this was changed round about 5.6.0 to expand qw(a b c) to the
list ('a', 'b', 'c') at compile-time rather than at run-time with a
hidden split. Maybe that's what caused you problems?

And as Aristotle said - that's not an array, so it's not the same thing.

What happens when you do

    @a = qw( foo bar bletch blort bim bam blort );
    my ( $a, $b, $c ) = @a;

?

Cheers,
Philip

Reply via email to