On Wed, 2006-01-11 at 09:25 -0500, Ricardo SIGNES wrote:

> @{ $children{$v} } means:
>   get the scalar stored in $children{$v} (which is an entry in
>   %children) and dereference it as an array
> 
> In other words:
> 
>   my $entry = $children{$v};
>   @$entry;
> 

First, Thank You for your reply.


I thought about that as a possibility, but rejected it because I never
saw the %children hash ever get initialized with even a single key/value
pair. As far as I can tell, $children{anything at all} is undef. I know
that's incorrect since the code works, but I can't see how it works. I
understand that autovivification is creating things on the fly as
needed, but see no mechanism to supply a key/value pair.

The push is extracting a value to be used as an array reference, but to
extract a value, one must be there to begin with and I can't see how a
value was ever supplied.


> @$children{$v}, which you suggested, would mean:
> 
>   get the hash slice of all entries in the hash to which $children
>   refers, containing the following keys: $v
> 
> In other words, with an only slight change in meaning:
> 
>   my $hashref = $children;
>   my %hash = %$hashref;
>   @hash{($v)};

I'll study that one after I TOTALLY understand my original problem.
Thank you for another eye opener & head scratcher.

-- 
Bill Gradwohl



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to