Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: How do I compare key from one hash with values from other?

by 2501 (Pilgrim)
on Dec 06, 2001 at 21:08 UTC ( [id://129995]=note: print w/replies, xml ) Need Help??


in reply to How do I compare key from one hash with values from other?

I am not quite sure I understood your question. Try this out..I think this kludge might be what you are looking for.

use strict; my %hash1 = ( A => 5, B => 7, C => 2, D => 8, ); my %hash2 = ( 1234 => "A,C", 4567 => "A,B,D", 5678 => "C", ); my %hash3; foreach my $key2 ( keys %hash2 ) { my %temphash = %hash1; foreach ( split /,/, $hash2{$key2} ) { delete $temphash{$_}; $hash3{$key2}= join ',', sort keys %temphash; } } foreach my $key ( keys %hash3 ) { print "$key : $hash3{$key}\n"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://129995]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-25 19:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found