|No such thing as a small change|
Stepping through a hash while modifiying its contentby Gorgarian (Initiate)
|on Dec 28, 2012 at 04:48 UTC||Need Help??|
Gorgarian has asked for the
wisdom of the Perl Monks concerning the following question:
Hi all in the monastry -- hope you are not all sworn to silence during the festive season.
I have a small challenge, being fairly new to perl. I wish to step through a hash with
but then modify the hash by deleting key,value pairs from the hash after some processing if they meet a certain condition, with the while loop in progress.
I have this nagging worry that modifiying the contents of the hash on the fly will stuff up the orderly progression of the while loop and that some records may be missed.
Can anyone with a deeper knowledge of perl advise on this?
A workaround would be to establish a companion array
but this doubles the memory requirements, and my files are huge. I would like to avoid this if it is not necessary.
Looking forward to hearing from you. My first post.