my $count = ($all_text =~ s/<<(\w+) .*? \1//gxms); $total += $count;