----- Original Message -----
From: Daniel Rychlik
Sent: 4/21/2006 2:36:57 PM
To: [EMAIL PROTECTED];[email protected]
Subject: RE: Updating Hash Elements

> What if I wanted to update another anonymous hash on the fly?
> 
> Lets say in a threaded loop I am keeping up with connection attempts and
> if they fail, I take the key from one anonymous hash and update another
> anonymous hash with that KEY and how many attempts...
> 
> So,
> 
> $ConnectionAttempts{'JOBID'} = { 'attempts' => +1 };

I think that what you mean is something like this:

$ConnecctionAttempts{'JOBID'} = { ++$other_hash{'attempts'} };

That takes the value of the key 'attempts' from the other hash (you did mention 
another hash, no?), increments it by one, and assigns the new value to the key 
'JOBID' in the $ConnectionAttempts hash.  Notice the ++ operator in _front_ of 
the variable; this makes sure that the value is incremented _before_ returning 
the new value and assigning it to the hash.

   -dZ.



_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to