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:
foreach $entry(@a){ if ($oldhash{$entry}==1 && $newhash{$entry}==0){ # push it into an array of deletions to be made } elsif($newhash{$entry}==1 && $oldhash{$entry}==0){ # ditto array of additions to be made } }
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
In reply to comparing two hashes by Cody Pendant
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |