my @match; { open my $fh, '<', $file or die "$!"; local $_; my $rx = qr/^$ARGV[0]\|/ m/$rx/ && push @match, $_ while <$fh>; }