Here's a simpler example that contains some tools that might be useful to you. (Sorry for the lazy hash declarations.) If you explain the bigger picture, you might get suggestions for data structures that can be manipulated more simply.

Katy

my %one = qw(_cat peach _dog apple _mouse apricot
            _rat tangerine _bat strawberry
            _snake loquat);

my %two = qw(fox mango wolf blueberry zebra kumquat rat banana
            bat papaya ratsnake pear bird orange);

my %keys = reverse map { /(_(.*))/ } keys %one;
my $ors = join('|', keys %keys);

foreach (grep { /$ors/ } keys(%two)) {
 print "$_ $one{$keys{$_}}\n" if defined($keys{$_});
}

On Tue, 25 Feb 2003 15:34:04 +0000, Aimal Pashtoonmal <[EMAIL PROTECTED]> wrote:

Hello people,

Can any one please help me. I have 2 hashes, hashA and hashB, the keys
in both cases, are made up of a mixture of numbers and words etc. But
the keys are differnt so I presume I cannot use if exits or if defined.

Is there anyway of check to see if the words and numbers making up the
keys of hashB are present in the keys of hashA?

ie:

initially I check if a certain word is present in key of hashA, such as
"if  ( $key =~ /WORD1/ ) { ....

then the key of hashA looks like: "12334RET    456    WORD1    W56778
sp_entry    14    30    0.001    T" (the value for this key is say
"1234.1")
and
the corresponding key of hashB looks like: "1234.1    A1    sp_entry
14    30    0.001" (the value for this key is say "1234.1.A1" )

What I am trying is if the key of hashA contain s "sp_entry"  && "14"
&& "30"  && "0.001" ; then to print the value held by the current key
of  hashB  ("1234.1.A1") followed by the entire current key of hashA
("12334RET    456    WORD1    W56778    sp_entry    14    30    0.001
T") so that the final output is:
"1234.1.A1    12334RET    456    WORD1    W56778    sp_entry    14
30    0.001    T" (all on the same line). The mixture of words and
numbers in the keys are seperated by a tab.

Thanks in advance for reading and reading with a reply.

cheers all, amal







-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to