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):
#!/usr/bin/env perl -l use strict; use warnings; use Inline::Files; my %vals = map { $_ => 1 } <VALUES>; print $_->[0] for grep { $vals{$_->[1]} } map { [ split / / ] } <TABLE +>; __TABLE__ xanmn_chr09_0114-xanmn_chr09_0114 3346 xanmn_chr09_0129-xanmn_chr09_0129 3358 xanmn_chr09_0116-xanmn_chr09_0116 3348 xanmn_chr09_0127-xanmn_chr09_0127 3354 __VALUES__ 3346 1933 1371 1448 2762 1395
Output:
xanmn_chr09_0114-xanmn_chr09_0114
See also: Inline::Files
-- Ken
|
|---|