Yes sir; Thank you...  

Works great.

-----Original Message-----
From: Chris O [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 21, 2006 11:31 AM
To: Daniel Rychlik; [email protected]
Subject: RE: Updating Hash Elements

Hello,

How does one update a hash element in PERL?

I am using anonymous hashes to process a file, and each element in the
anonymous has its own value...  

If the file has success on process, I delete the hash element from the
anonymous hash...  

If it the file fails to process, I need to increment the attempts to the
next higher number...  

I tried this,

If ($HASH{KEY}->{attempts} != '5') {

        $attempted = $HASH{KEY}->{attempts} + '1';

        $HASH{KEY}->{attempts} => $attempted; #Update the hash key

} else {

        Move the file to the error folder...  
        
}

When I run it, I get "Useless use of hash element in void context.
Useless
use of private variable in void context...

How could this better be written?

-Dan
--------------------------------------------------------------


Juse a guess, but is this what your looking for?

- Chris


if(!$HASH{KEY}->{attempts}){
        
        $HASH{KEY}->{attempts}=1;

}elsif($HASH{KEY}->{attempts} != '5') {

        $HASH{KEY}->{attempts}++; # Add 1 to the hash key

} else {

        # Move the file to the error folder...
        
}


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

Reply via email to