At 11:46 PM 8/31/00 +0200, Bart Lateur wrote:
>On Fri, 1 Sep 2000 07:27:24 +1100 (EST), Damian Conway wrote:
>
> >  > > And has anyone pointed out that C<list> is just:
> >   > >
> >   > > sub list {@_}
> >   >
> >   > Um no. I would expect it to be
> >   >
> >   >   sub list { @_[0..$#_] }
> >
> >It's too early in the morning.
> >The subtlety here escapes me.
>
>It's the difference between an array and a list.
>
>         sub array { @_ }
>         sub list { @_[0..$#_] }
>         @a = qw(a b c);
>         $\ = "\n"
>         print scalar array @a;
>         print scalar list @a;
>-->
>         3
>         c

I guess this is due to the combination of:

   1. Context reaches down through stack frames to find its victim^Wargument
   2. Arrays in a scalar context evaluate to their number of entries
   3. Array slices evaluate to the list of their members

Each one is reasonable, but boy, put them together and you can trip up even 
the wiley Antipodean Perl master (albeit in a chronically challenged 
state... so to speak).

This is the kind of thing that keeps Perl instructors in business...
--
Peter Scott
Pacific Systems Design Technologies

Reply via email to