Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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

by kcott (Abbot)
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


Comment on Re: How to compare hash values to array values in Perl
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2015-07-05 09:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (61 votes), past polls