in reply to searching something IN a regex ?
Barring additional information, you're probably best off using a hash to index captured values. Something like:
use strict; use warnings; my %matches = (); while (<DATA>) { if (/Good\s(\d)/) { $matches{$1}++; } } foreach my $key (keys %matches) { print "$key: $matches{$key}\n"; } __DATA__ Good 1 Good 2 Good 3 Bad 1 Bad 2 Bad 1 Good 3 Good 1
|
|---|