in reply to Map function slowing down program

You're compiling the same regular expressions over and over again, once for every line in the second file. Note the use of qr// below.
#!/usr/bin/perl -w use strict; my @regexps; { my $fn = $ARGV[0]; open(my $fh, '<', $fn) or die "Cannot open pattern file \"$fn\": $!\n"; while( <$fh> ) { chomp; my ($pat) = /(\S+)\s+\S+/ or next; push @regexps, qr/$pat/; } } { my $fn = $ARGV[1]; open(my $fh, '<', $fn) or die "Cannot open data file \"$fn\": $!\n"; while ( <$fh> ) { chomp; my $cnt = 0; for my $re (@regexps) { ++$cnt if /$re/; } print "$cnt $_\n"; } }

Other improvements:

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.