use strict; use warnings; my $re0; my $re1; our $s_pos; $re1 = qr/ (?{ local $s_pos = pos; }) [A-Z] (?{ print("[", substr($_, $s_pos, pos()-$s_pos), "]\n") }) /x; $re0 = qr/ (?: (??{ $re1 }) )+ /x; 'abcDE' =~ $re0; __END__ output ====== (?: (??{ $re1 }) )+ matches null string many times before HERE mark in regex m/ (?: (??{ $re1 }) )+ << HERE / at script.pl line 19. [D] [E] #### use strict; use warnings; my $re0; my $re1; $re1 = qr/ ([A-Z]) (?{ print("[$1]\n") }) /x; $re0 = qr/ (?: () (??{ $re1 }) )+ /x; 'abcDE' =~ $re0; __END__ (?: () (??{ $re1 }) )+ matches null string many times before HERE mark in regex m/ (?: () (??{ $re1 }) )+ << HERE / at script.pl line 17. [D] [E]