in reply to Printing the count for regex matches
How's this? I used (?:) to shorten the regex; and parens in the join to get rid of the dangling comma.
use strict; use warnings; my @matches; while (<DATA>) { push @matches, $1 if /((?:first|second|third|fourth|fifth)_string)/ +; } print scalar @matches, " matches found: ", join(", ", @matches), "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Printing the count for regex matches
by CountZero (Bishop) on Mar 10, 2009 at 05:49 UTC |