local $_ = "abcdef"; my $count; /..*..*.(?{$count++})(?!)/; print "$count matches\n"; ## "20 matches"