$_ = "abcabcabc"; while (/c/g && /a/g) { say pos; } __END__ Output: 4 7