Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: Compare Values in HoH

by MidLifeXis (Monsignor)
on Apr 06, 2006 at 18:09 UTC ( [id://541689]=note: print w/replies, xml ) Need Help??


in reply to Re: Compare Values in HoH
in thread Compare Values in HoH

Small logic error which you catch after the fact in your output loop.

Assuming unique values in each file, your loops can be reduced to

foreach my $entry (@file1) { $index{$entry} = 1 } foreach my $entry (@file2) { $index{$entry} += 2; }

Not assuming unique values, to avoid "screwed up" entries, it could be reduced to this

foreach my $entry (@file1) { $index{$entry} = 1 } foreach my $entry (@file2) { # '||0' is to still the warnings under 'use warnings' $index{$entry} += 2 if (($index{$entry}||0) < 2); }

Nothing big.

--MidLifeXis

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2024-04-19 09:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found