I spoke too soon, kinda.
pos works, but gives a weird warning when + is used:
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]
Same with the extra capture:
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]
However, the warning seems to be spurious. The warning check is using a variable that's not updated, but the pos truly is changing.
In reply to Re^2: Using a capture in /(?{...})/
by ikegami
in thread Using a capture in /(?{...})/
by ikegami
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |