$count += () = $teststring =~ /(test)/g; #### @matches = $teststring =~ /(test)/g; #### $count += @matches;