Perl Hash Comparison and concatenate result from %hash2 compared to%hash1 into %hash3
Hi,
How do I compare the column 1 in %hash2, with column 1 in %hash1 so
that when a match is found
to append or concatenate the hash key (column 1) and it's associated
values from %hash2 with that
of %hash1 and build a new hash %hash3 as the end result.
%hash1
emcpowera =A0 sdbd sddg sdfj sdhm
emcpoweraa =A0sdae sdch sdek sdgn
emcpowerbc =A0sdb sdbe sddh sdfk
emcpowerc =A0 sdbb sdde sdfh sdhk
emcpowerd =A0 sdba sddd sdfg sdhj
%hash2
emcpowera1 =A0/dwpdb006
emcpoweraa1 /dwpdb033
emcpowerbc1 /s00_11
emcpowerbc2 /utl_file_dir
emcpowerc1 =A0/odsdb006
emcpowerd1 =A0/odsdb005
This is what the end result should look like:
%hash3
emcpowera =A0 sdbd sddg sdfj sdhm =A0emcpowera1 =A0/dwpdb006
emcpoweraa sdae sdch sdek sdgn =A0emcpoweraa1 /dwpdb033
emcpowerbc =A0sdb sdbe sddh sdfk =A0 emcpowerbc1 /s00_11
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 sdba sddd sdfg sdhj =A0emcpowerbc2 /u=
tl_file_dir
emcpowerc =A0 sdbb sdde sdfh sdhk =A0emcpowerc1 =A0/odsdb006
emcpowerd =A0 sdba sddd sdfg sdhj =A0emcpowerd1 =A0/odsdb005
emcpowerz =A0 sdbg sddv sdfd sdht
--
Thanks,
Wernher
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Re: Perl Hash Comparison and concatenate result from %hash2 comparedto %hash1 into %hash3
Wernher Eksteen wrote:
> Hi,
Hello,
> How do I compare the column 1 in %hash2, with column 1 in %hash1 so
> that when a match is found
> to append or concatenate the hash key (column 1) and it's associated
> values from %hash2 with that
> of %hash1 and build a new hash %hash3 as the end result.
>
> %hash1
> emcpowera sdbd sddg sdfj sdhm
> emcpoweraa sdae sdch sdek sdgn
> emcpowerbc sdb sdbe sddh sdfk
> emcpowerc sdbb sdde sdfh sdhk
> emcpowerd sdba sddd sdfg sdhj
>
> %hash2
> emcpowera1 /dwpdb006
> emcpoweraa1 /dwpdb033
> emcpowerbc1 /s00_11
> emcpowerbc2 /utl_file_dir
> emcpowerc1 /odsdb006
> emcpowerd1 /odsdb005
>
> This is what the end result should look like:
>
> %hash3
> emcpowera sdbd sddg sdfj sdhm emcpowera1 /dwpdb006
> emcpoweraa sdae sdch sdek sdgn emcpoweraa1 /dwpdb033
> emcpowerbc sdb sdbe sddh sdfk emcpowerbc1 /s00_11
> sdba sddd sdfg sdhj emcpowerbc2 /utl_file_dir
^^^^^^^^^^^^^^^^^^^
Why is this list
> emcpowerc sdbb sdde sdfh sdhk emcpowerc1 /odsdb006
> emcpowerd sdba sddd sdfg sdhj emcpowerd1 /odsdb005
^^^^^^^^^^^^^^^^^^^
the same as this list?
> emcpowerz sdbg sddv sdfd sdht
^^^^^^^^^^^^^^^^^^^
Where did this list come from?
John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction. -- Albert Einstein
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/