[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] pop (keys %hash) ?



On Fri, Jun 18, 1999 at 03:33:25PM -0400, Shawn O'Donnell wrote:
> At 1:46 PM -0400 6/18/99, Chris Nandor wrote:
> >You could do something like:
> >
> >  $element = pop @{[keys %hash]};
> >
> >This puts keys %hash into an anonymous array reference [], and then @{}
> >dereferences it to be used as an array.
> >
> 
> Interesting, but I'm confused by the documentation.  perlfunc says
> 
>      keys HASH
> 
>          Returns a normal array consisting of all the keys of the
>          named hash.
> 
> Is a "normal array" different than "array"?  pop wants an array.
> 
> Leaving aside the problem of lastness in a hash, why can't you pop 
> off the array returned by keys HASH?
> 
> I sense there's something subtle but significant here that I'm not 
> understanding.
> 

The documentation is incorrect.  keys() returns a list, not an array.
Perl functions cannot return arrays, only lists.

This has been fixed for keys() and values () in the documentation for
5.005_02.

Ronald


===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org