print $1 while 'abcdefghijkl' =~ m[(.{3})]g;; abc def ghi jkl use constant LEN => 3;; print $1 while 'abcdefghijkl' =~ m[(.{LEN})]g;; ## notable absence of output mean the regex matched nothing (very, very quickly).