Edward Wijaya wrote on 01.10.2004:
>On Thu, 30 Sep 2004 14:23:47 -0300, Shaw, Matthew <[EMAIL PROTECTED]>
>wrote:
>
>Thanks Matt,
>
>
>>> > my %HoA = (key1 => ['A',1]);
>>> > my %HoA2 = (key1 => ['B',2]);
>>> > my %HoA3 = (key1 => ['C',2]);
>>> >
>>> > into:
>>> >
>
>Only this one works
>
>>> push @{$HoA{key1}}, ( @{$HoA2{key1}}, @{$HoA2{key1}});
>
>
>Not this
>> Sorry this should read:
>> @{$HoA{key1}}, ( @{$HoA2{key1}}, @{$HoA3{key1}});
>
>However what it gives is that it create one single array,
>and not preserving the array that group ['A',1] etc, like before
>namely:
>
>print Dumper \%HoA;
>$VAR1 = {
> 'key1' => [
> 'A',
> 1,
> 'B',
> 2,
> 'C',
> 2
> ]
> };
>
>not;
>
>$VAR1 = { 'key1' => ['A',1],['B',2],['C',2]};
So you want a hash of an array of arrays, right? This is adding another level of
encapsulation.
So you could do this
#get the actual length of your target array and add one
$array_element = $#HoA{key1}++;
#push the new list of values into a new array inside the HoA
push $HoA{key1}->[$array_element], @{$HoA2{key1}}
Or did I get you wrong?
- Jan
--
There's no place like ~/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>