Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: How to compare hash values to array values in Perl

by kcott (Canon)
on May 14, 2014 at 05:18 UTC ( #1085977=note: print w/replies, xml ) Need Help??

in reply to How to compare hash values to array values in Perl

G'day To_Bz,

Welcome to the monastery.

You can achieve that much more simply like this:

my %vals = map { $_ => 1 } <FILE2>; print $_->[0] for grep { $vals{$_->[1]} } map { [ split / / ] } <FILE1 +>;

I would, however, recommend you use lexical filehandles. See open for examples.

Here's my test (in the spoiler):

-- Ken

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1085977]
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: (13)
As of 2016-10-24 15:57 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (309 votes). Check out past polls.