"ANJAN PURKAYASTHA" schreef:
> i'm struggling with a hash of arrays problem.
> suppose i create the following HOA:
> $HOA{$key}= [qw(a,b,c,d)];
which is equivalent to
$HOA{ $key } = [ 'a', 'b', 'c', 'd' ];
and can also be written as
$HOA{ $key } = [ 'a' .. 'd' ];
> how do i push an element into the $HOA{$key} array?
Pushing is done on arrays, at the top.
You have an array reference in $HOA{ $key }, so first you need to
dereference it, by applying @{ }.
push @{ $HOA{ $key } }, 'element';
If by "into" you meant an insertion at the start or middle, read the
documentation of shift (`perldoc -f shift`) and about array slices in
perldata (`perldoc perldata`).
--
Affijn, Ruud
"Gewoon is een tijger."
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/