http://www.perlmonks.org?node_id=1085977


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