http://qs321.pair.com?node_id=902965


in reply to Re: Reconcile one list against another
in thread Reconcile one list against another

Holy mackerel... So, if I make each line a hash key, and iterate over users I should increment hash value for each time I get a user match against the line.

Then just print out the hash for keys that are zero, or greater than one, depending on whether or not I want to see a list of users that do no match, or do match respectively!

I think that will work. Stay tuned for code...

Very funny Scotty... Now PLEASE beam down my PANTS!

  • Comment on Re^2: Reconcile one list against another

Replies are listed 'Best First'.
Re^3: Reconcile one list against another
by samwyse (Scribe) on May 04, 2011 at 21:03 UTC
    Here's a simple way to take the difference of sets.
    use Data::Dumper; %one = ( 'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5, 'f' => 6,); %two = ( 'a' => -1, 'e' => -2, 'i' => -3, 'o' => -4, 'u' => -5,); print Dumper(\%one, \%two); %tmp = %one; delete @tmp{keys %two}; print Dumper(\%tmp); %tmp = %two; delete @tmp{keys %one}; print Dumper(\%tmp);
    Running the above produces the following:
    $VAR1 = { 'e' => 5, 'c' => 3, 'a' => 1, 'b' => 2, 'd' => 4, 'f' => 6 }; $VAR2 = { 'e' => -2, 'u' => -5, 'a' => -1, 'o' => -4, 'i' => -3 }; $VAR1 = { 'c' => 3, 'b' => 2, 'd' => 4, 'f' => 6 }; $VAR1 = { 'u' => -5, 'i' => -3, 'o' => -4 };