> Hi Everybdy,
> 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.
Hi,
I'm not sure you can just go "hash = array" as they're somewhat different, in the same
way you can't go "scalar = array" (you can but it won't do what you think). But you
can assign the hash the reference of the array. For example:
$hash{1} = [EMAIL PROTECTED];
Or:
push(@{$hash{1}}, @array);
Then to loop through the array whose reference is assigned to $hash{1} you can do:
foreach(@{$hash{1}})
{
# do something with $_
}
Cheers!
________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit
http://www.messagelabs.com
________________________________________________________________________
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>