in reply to Counting frequency of the regex matches
This example assumes you want to stop once you have matched something. By making the last re match anything you can keep track of the number of unmatched rows without special casing it. That is, $matches[-1] is the number of rows that didn't match any of the other regular expressions.my @res = ( qr/this/, qr/that/, ..., qr//); my @matches; for each row $row: for my $i (0..$#res) { if ($row =~ m/$res[$i]/) { $matches[$i]++; last; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Counting frequency of the regex matches
by throop (Chaplain) on Jun 06, 2008 at 04:23 UTC | |
by parv (Parson) on Jun 06, 2008 at 05:09 UTC | |
by pc88mxer (Vicar) on Jun 06, 2008 at 06:29 UTC |