hash comparison

hash comparison

am 15.12.2005 23:26:40 von bill

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

Re: hash comparison

am 16.12.2005 00:51:00 von Jim Gibson

In article , Bill
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

Re: hash comparison

am 16.12.2005 01:26:51 von Matt Garrish

"Bill" wrote in message
news:A4mof.86634$65.2505133@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