in reply to Re: Re: Re: Re: Link a hash and an array
in thread Link a hash and an array
Working from the inside out. $_[0] is the 0th element of @_. If its value is "addr", then the value of $Types{"addr"} is \@Address (a reference to the global @Address).@Stuff{@{$Types{$_[0]}}} = @_;
@{\@Address} takes the reference and "returns" the array it points to. @Stuff{@Address}, known as a "hash slice", is assigned the values in the @_ array, and is equivalent to this:
A hash slice is just shorthand for this:@Stuff{@Address} = qw(addr bob smith '1234 main st' anytown 20500);
$Stuff{type} = 'addr'; $Stuff{firstname} = 'bob'; ... $Stuff{zip} = '20500';
[I hope that was clear]
-QM
--
Quantum Mechanics: The dreams stuff is made of
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Re: Re: Link a hash and an array
by SkipHuffman (Monk) on Mar 12, 2004 at 17:52 UTC |