in reply to Re^2: emulate "fgrep -f file" with results ordered by "file"
in thread emulate "fgrep -f file" with results ordered by "file"

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

Replies are listed 'Best First'.
Re^4: emulate "fgrep -f file" with results ordered by "file"
by coldy (Scribe) on Mar 15, 2011 at 03:19 UTC
    thankyou very fast indeed!