in reply to RE: Count String Occurrences
in thread Count String Occurrences

If you're going to do that to save memory, ditch the array altogether (as an SV tends to be smaller than an AV): my $count = scalar(() = $string =~ /abc/g); The blank list gives us list context, while scalar gets the number of items that would be in the list... if it weren't blank. :)