Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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 drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2015-03-28 18:43 GMT
Find Nodes?
    Voting Booth?

    When putting a smiley right before a closing parenthesis, do you:

    Results (625 votes), past polls