in reply to comparing two hashes
What you're really trying to do is subtract one set from another set. Hashes are the right tool, but this can be done with slices instead of loops.
# find old values that are not in new values my %deletions; @deletions{@oldvalues} = (); delete @deletions{@newvalues}; my @deletions = keys %deletions; # find new values that are not in old values my %additions @additions{@newvalues} = (); delete @additions{@oldvalues}; my @additions = keys %additions;
Update: fixed hash names.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: comparing two hashes
by rinceWind (Monsignor) on Feb 24, 2002 at 22:14 UTC | |
Re: Re: comparing two hashes
by Cody Pendant (Prior) on Feb 24, 2002 at 23:16 UTC | |
by screamingeagle (Curate) on Feb 25, 2002 at 03:09 UTC |
In Section
Seekers of Perl Wisdom