$ perl -we'use re "debug"; $x=qr/(.)\1|(.)(??{$x})\2/; "abcddcba" =~ /^$x\z/' Compiling REx `(.)\1|(.)(??{$x})\2' size 20 Got 164 bytes for offset annotations. 1: BRANCH(9) 2: OPEN1(4) 4: REG_ANY(5) 5: CLOSE1(7) 7: REF1(20) 9: BRANCH(20) 10: OPEN2(12) 12: REG_ANY(13) 13: CLOSE2(15) 15: LOGICAL[2](16) 16: EVAL(18) 18: REF2(20) 20: END(0) minlen 1 with eval Offsets: [20] 0[0] 1[1] 0[0] 2[1] 3[1] 0[0] 4[2] 0[0] 6[1] 7[1] 0[0] 8[1] 9[1] 0[0] 17[0] 17[0] 0[0] 18[2] 0[0] 20[0] Compiling REx `^(?-xism:(.)\1|(.)(??{$x})\2)\z' size 23 Got 188 bytes for offset annotations. first at 2 1: BOL(2) 2: BRANCH(10) 3: OPEN1(5) 5: REG_ANY(6) 6: CLOSE1(8) 8: REF1(22) 10: BRANCH(21) 11: OPEN2(13) 13: REG_ANY(14) 14: CLOSE2(16) 16: LOGICAL[2](17) 17: EVAL(19) 19: REF2(22) 21: TAIL(22) 22: EOS(23) 23: END(0) floating `'$ at 1..2147483647 (checking floating) anchored(BOL) minlen 1 with eval Offsets: [23] 1[1] 9[1] 10[1] 0[0] 11[1] 12[1] 0[0] 13[2] 0[0] 15[1] 16[1] 0[0] 17[1] 18[1] 0[0] 26[0] 26[0] 0[0] 27[2] 0[0] 28[0] 30[2] 32[0] Guessing start of match, REx `^(?-xism:(.)\1|(.)(??{$x})\2)\z' against `abcddcba'... Found floating substr `'$ at offset 8... Guessed: match at offset 0 Matching REx `^(?-xism:(.)\1|(.)(??{$x})\2)\z' against `abcddcba' Setting an EVAL scope, savestack=15 0 <> | 1: BOL 0 <> | 2: BRANCH Setting an EVAL scope, savestack=21 0 <> | 3: OPEN1 0 <> | 5: REG_ANY 1 | 6: CLOSE1 1 | 8: REF1 failed... 0 <> | 11: OPEN2 0 <> | 13: REG_ANY 1 | 14: CLOSE2 1 | 16: LOGICAL[2] 1 | 17: EVAL re_eval 0x1003bb30 Entering embedded `(.)\1|(.)(??{$x})\2' Setting an EVAL scope, savestack=35 1 | 1: BRANCH Setting an EVAL scope, savestack=41 1 | 2: OPEN1 1 | 4: REG_ANY 2 | 5: CLOSE1 2 | 7: REF1 failed... 1 | 10: OPEN2 1 | 12: REG_ANY 2 | 13: CLOSE2 2 | 15: LOGICAL[2] 2 | 16: EVAL re_eval 0x10019550 Entering embedded `(.)\1|(.)(??{$x})\2' Setting an EVAL scope, savestack=55 2 | 1: BRANCH Setting an EVAL scope, savestack=61 2 | 2: OPEN1 2 | 4: REG_ANY 3 | 5: CLOSE1 3 | 7: REF1 failed... 2 | 10: OPEN2 2 | 12: REG_ANY 3 | 13: CLOSE2 3 | 15: LOGICAL[2] 3 | 16: EVAL re_eval 0x10019550 Entering embedded `(.)\1|(.)(??{$x})\2' Setting an EVAL scope, savestack=75 3 | 1: BRANCH Setting an EVAL scope, savestack=81 3 | 2: OPEN1 3 | 4: REG_ANY 4 | 5: CLOSE1 4 | 7: REF1 5 | 20: END Setting an EVAL scope, savestack=95 restoring \1 to 2(2)..-1 restoring \2 to 2(2)..3 5 | 18: REF2 6 | 20: END Setting an EVAL scope, savestack=109 restoring \1 to 1(1)..-1 restoring \2 to 1(1)..2 6 | 18: REF2 7 | 20: END Setting an EVAL scope, savestack=123 restoring \1 to 0(0)..-1 restoring \2 to 0(0)..1 7 | 19: REF2 8 <> | 22: EOS 8 <> | 23: END Match successful! Freeing REx: `"^(?-xism:(.)\\1|(.)(??{$x})\\2)\\z"' Freeing REx: `"(.)\\1|(.)(??{$x})\\2"'