#!/usr/bin/perl use strict; use warnings; my $str = "this is abc and bcf and xyz and ijklmn"; while ($str =~ m{ ( # capture to $1 . # any character (?: # this chunk: $ # either the end of the string | (??{ chr(1 + ord substr($&, -1)) }) # or the next character (ASCII-wise) after # the one we just matched )+ # one or more times ) # end capture }xgs) { print "run: <$1>\n"; } #### (?: # this chunk: $ # either the end of the string | (??{ chr(1 + ord substr($&, -1)) }) # or the next character (ASCII-wise) after # the one we just matched )+ # one or more times matches null string many times in regex; marked by <-- HERE in m/ ( # capture to $1 . # any character (?: # this chunk: $ # either the end of the string | (??{ chr(1 + ord substr($&, -1)) }) # or the next character (ASCII-wise) after # the one we just matched )+ # one or more times <-- HERE ) # end capture / at ./x line 17. run: run: run: run: run: