That's a very cool way of solving this problem, I learned quite a bit from reading it. I noticed that this returns lines that contain at least one element in
@arr. I made a simple modification to the second algorithm to only return lines that have all elements in
@arr. The OP didn't specify if he meant one or all array elements, so here's my modification for brevity's sake.
my (%hsh, @keepers);
@hsh{@arr} = ();
while (<>) {
push @keepers, $_ unless grep {!exists $hsh{$_}} split;
}
Thanks for enlightening me with that code sample
Zaxo