From: "Jeff Pang" <[EMAIL PROTECTED]>
> On 10/22/07, Rodrigo Tavares <[EMAIL PROTECTED]> wrote:
> > Hello,
> >
> > I would like, put element's array in hash table.
> > How I can do it ?
> >
>
> Hi,
>
> use AoH,like,
>
> my @array = (1,2,3,4);
> my %hash = (key1 => [EMAIL PROTECTED]);
>
> then you can access the array's first element by,
>
> $hash{key1}->[0];
>
> the second element by,
>
> $hash{key1}->[1];
>
> and so on.
You can actually skip the ->.
$hash{key1}->[0] == $hash{key1}[0]
On the other hand if you have a reference to a hash in a variable you
can't skip the first -> :
$hashref->{key}->[0]
is equivalent to
$hashref->{key}[0]
but not to
$hashref{key}[0]
!
Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/