Jan Eden wrote:
> 
> Soumyadeep nandi wrote:
> 
> >I am stuck in a problem for which I need your help. My
> >problem spins around adding an element in an array
> >within a hash.
> >I have a hash declared as $hash{"1"[EMAIL PROTECTED]; now I
> >want to add an element to it within a loop. How would
> >I do this? I would be highly grateful to you if you
> >could help me.
> 
> Your syntax puts a number (the number of elements in @array into $hash{"1"}.
> 
> I guess you want to set an array reference as the hash key's value:
> 
> $hash{"1"} = [EMAIL PROTECTED];
> 
> In that case, you can just
> 
> push @{$hash{"1"}}, $_ for (...list goes here...);
> 
> to push into the array referenced by $hash{"1"}.

The second argument of push() is a list so you don't need a for loop
there.

push @{$hash{"1"}}, (...list goes here...);


:-)
John
-- 
use Perl;
program
fulfillment

-- 
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