Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Compare Values in HoH

by GrandFather (Cardinal)
on Apr 06, 2006 at 09:04 UTC ( #541602=note: print w/ replies, xml ) Need Help??


in reply to Compare Values in HoH

One way to do it is to generate a lookup hash keyed on your search data. Here's a starting point:

use warnings; use strict; my @file1 = ( '1141286452,ServerA,Disk Full', '1141286737,ServerB,Net Down', '1141286737,ServerC,Disk Full' ); my @file2 = ( '1141286737,ServerB,Net Down', '1141286780,ServerD,Bit Bucket Missing' ); my %file1LookUp; push @{$file1LookUp{$file1[$_ - 1]}}, $_ for (1..@file1); for (@file2) { print "Matched $_ at line(s) @{$file1LookUp{$_}}\n" if exists $fil +e1LookUp{$_}; }

Prints:

Matched 1141286737,ServerB,Net Down at line(s) 2

DWIM is Perl's answer to Gödel


Comment on Re: Compare Values in HoH
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2014-09-24 04:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (245 votes), past polls