@test = ('foobarfoo', 'blahbarblah', 'bazbarbarbarbaz'); while (@test) { # # $_ has foobarfoo or blahbarblah or bazbarbarbarbaz # while(/bar/g) { # # matched bar once in foobarfoo inc by 1 # matched bar once in blahbarblah inc by 1 # matched bar 3 times in bazbarbarbarbaz inc by 1 3 times # $count++; print "$count so far\n"; } }