You could create an index (=hash lookup table) by the first field of 'large'. Then loop over @list and check if the key exists in the lookup table.
Something like
my %index; while (<DATA>) { # your $large my ($f1) = split; $index{$f1} .= $_; } my @list = qw(foo r2c1 bar r3c1); for (@list) { print $index{$_} if exists $index{$_}; } __DATA__ r1c1 r1c2 r1c3 r2c1 r2c2 r2c3 r3c1 r3c2 r3c3
In reply to Re^3: emulate "fgrep -f file" with results ordered by "file"
by Eliya
in thread emulate "fgrep -f file" with results ordered by "file"
by coldy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |