On Sun, 6 Oct 2002, Luke Palmer wrote:

> > Do parens still provide list context on the left side of an assignment?
> > What do these two do:
> >
> >   my $x = @ARGS;
> >   my ($y) = @ARGS;
> >
> > Parens just grouping suggests that C<$x> and C<$y> should be the same
> > (which may well be good, as it's a subtle distinction which trips up
> > many beginners in Perl 5).  If so, what's the preferred way of getting
> > the 'other' behaviour?
> 
> Maybe:?
> 
>       my ($y) ^= @ARGS;

That's like saying 
    $y = @ARGS[$_] for 0..+@ARGS;
so $y will probably end up with the _last_ element of @ARGS.

I suggest:

    my $y = shift;       # if this still works in perl6
    my $y = @ARGS[0];

~ John Williams


Reply via email to