in reply to regex persistence of matches

You might try something like this:

#!/perl/bin/perl -w use strict; my $str = 'ffggffffhhffii'; my $searchstr1 = 'ff'; my $searchstr2 = 'ee'; my @ary1 = $str =~ /$searchstr1/g; my @ary2 = $str =~ /$searchstr2/g; printf qq("%s" matches "%s" %d times.\n), $searchstr1, $str, scalar @a +ry1; printf qq("%s" matches "%s" %d times.\n), $searchstr2, $str, scalar @a +ry2; __OUTPUT__ "ff" matches "ffggffffhhffii" 4 times. "ee" matches "ffggffffhhffii" 0 times.

Update: Ugh! First solution was borked... this version works better...

Update2: Removed unnecessary parentheses from regex


Where do you want *them* to go today?