in reply to counting matches in a line
$_ = "abffdeabggfrabhhjuab"; my $matches =()= m/ab/g; print $matches; # 4
See Perl Idioms Explained - my $count = () = /.../g for an explanation of =()=, the operator-that-shall-not-be-named :)
Update: Removed superfluous brackets from regexp & added a linky
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: counting matches in a line
by halfcountplus (Hermit) on Mar 16, 2008 at 23:33 UTC |