my $pattern = join '|', @ids; print grep {/$pattern/} <>;