Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Compare Values in HoH

by GrandFather (Sage)
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{$_}; }


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?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (12)
As of 2015-08-03 16:33 GMT
Find Nodes?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...

    Results (45 votes), past polls