my $match_cnt = grep { $_ =~ /$pattern/ } @input;