Daniel Rychlik <> wrote:
> Hello,
> 
> How does one update a hash element in PERL?

See 'perldoc -q "Perl.*and.*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';

Loose the quotes in the above 2 lines. They are numbers, not strings.

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

That should be assignment (i.e. '='), not the special comma operator
(i.e. '=>').

However, it is a lot simpler to use the pre- or post-increment
operators. For example:

++$HASH{KEY}->{attempts};

See 'perldoc perlop'.

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

HTH

-- 
Brian Raven 


=================================
Atos Euronext Market Solutions Disclaimer
=================================
The information contained in this e-mail is confidential and solely for the 
intended addressee(s). Unauthorised reproduction, disclosure, modification, 
and/or distribution of this email may be unlawful.
If you have received this email in error, please notify the sender immediately 
and delete it from your system. The views expressed in this message do not 
necessarily reflect those of Atos Euronext Market Solutions.

L'information contenue dans cet e-mail est confidentielle et uniquement 
destinee a la (aux) personnes a laquelle (auxquelle(s)) elle est adressee. 
Toute copie, publication ou diffusion de cet email est interdite. Si cet e-mail 
vous parvient par erreur, nous vous prions de bien vouloir prevenir 
l'expediteur immediatement et d'effacer le e-mail et annexes jointes de votre 
systeme. Le contenu de ce message electronique ne represente pas necessairement 
la position ou le point de vue d'Atos Euronext Market Solutions.


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

Reply via email to