in reply to Re^2: My code sucks, please help me understand why.
in thread My code sucks, please help me understand why.

my @pids; { open(my $pids_fh, '<', $pids_qfn) or die("Can't open PIDS file \"$pids_qfn\": $!\n"); push @pids, /\|(\d+)$/ while <$pids_fh>; } my $pids_pat = map qr/$_/, join '|', #map quotemeta, # We're only dealing with digits @pids; open(my $fids_fh, '<', $fids_qfn) or die("Can't open FIDS file \"$fids_qfn\": $!\n"); while (<$fids_fh>) { print if /^$pids_pat;/; }

If you need extra speed and your Perl is older than 5.10, change

my $pids_pat = map qr/$_/, join '|', #map quotemeta, # We're only dealing with digits @pids;
to
use Regexp::List qw( ); my $pids_pat = Regexp::List->new()->list2re(@pids);

5.10 already does the optimisation Regexp::List does.