- or download this
my @match = do {
open my $fh, '<', $file or die "$!";
grep /^$ARGV[0]\|/, <$fh>;
};
- or download this
my @match;
{
...
my $rx = qr/^$ARGV[0]\|/
m/$rx/ && push @match, $_ while <$fh>;
}
- or download this
sub grep_file {
my ($rx, $file) = @_;
...
};
my @match = grep_file($ARGV[0], $file);