hash comparison

Hello

is there a module, or what is the best way to compare two
hashes and have the differences ?

something like

my %newab = compare(%a,%b)

in %newab i need the values that are in %a but not in %b
and vicevers

my %newba = compare(%b,%a)

thank you

Bye
bill [ Do, 15 Dezember 2005 23:26 ] [ ID #1104077 ]

Re: hash comparison

In article <A4mof.86634$65.2505133 [at] twister1.libero.it>, Bill
<bill [at] coldmail.com> wrote:

> Hello
>
> is there a module, or what is the best way to compare two
> hashes and have the differences ?
>
> something like
>
> my %newab = compare(%a,%b)
>
> in %newab i need the values that are in %a but not in %b
> and vicevers
>
> my %newba = compare(%b,%a)

Check out List::Compare and use it on the keys of your hashes.

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Jim Gibson [ Fr, 16 Dezember 2005 00:51 ] [ ID #1105697 ]

Re: hash comparison

"Bill" <bill [at] coldmail.com> wrote in message
news:A4mof.86634$65.2505133 [at] twister1.libero.it...
> Hello
>
> is there a module, or what is the best way to compare two
> hashes and have the differences ?
>
> something like
>
> my %newab = compare(%a,%b)
>
> in %newab i need the values that are in %a but not in %b
> and vicevers
>

See the entry that deal with this problem in perlfaq4: How can I get the
unique keys from two hashes?

Matt
Matt Garrish [ Fr, 16 Dezember 2005 01:26 ] [ ID #1105698 ]
Perl » alt.perl » hash comparison

Vorheriges Thema: Perl script for scanning files
Nächstes Thema: Re: perl test