Your skill will accomplish what the force of many cannot |
|
PerlMonks |
comparing two hashesby Cody Pendant (Prior) |
on Feb 24, 2002 at 06:06 UTC ( [id://147150]=perlquestion: print w/replies, xml ) | Need Help?? |
Cody Pendant has asked for the wisdom of the Perl Monks concerning the following question:
I've got a situation where there are a hundred items, either true or false. I've got the old list of which ones are true or false, and I've edited it using a web form, probably removing some from the "true" list and adding others to it. Having submitted the form, what's the best way to reset the list correctly? I did it like this: I made a hash of 100 entries all set to zero, then did a foreach on the list of old items, and set the right values to 1. Then I made a hash of 100 entries all set to zero and did a foreach loop on the list of new items, setting the right values to 1. Then I went through the hash keys like this:
I've been staring at this code for a while and I can't figure out if that's a dumb way to do it or not, but it feels kind of dumb.
Is there a smarter way?
Edit: chipmunk 2002-02-24
Back to
Seekers of Perl Wisdom
|
|