[~] $ perl -Mre=debug -we'$_ = "abbaba"; /(.).*?\1/' Freeing REx: `,' Compiling REx `(.).*?\1' size 11 first at 3 1: OPEN1(3) 3: REG_ANY(4) 4: CLOSE1(6) 6: MINMOD(7) 7: STAR(9) 8: REG_ANY(0) 9: REF1(11) 11: END(0) minlen 1 Omitting $` $& $' support. EXECUTING... Matching REx `(.).*?\1' against `abbaba' Setting an EVAL scope, savestack=3 0 <> | 1: OPEN1 0 <> | 3: REG_ANY 1 | 4: CLOSE1 1 | 6: MINMOD 1 | 7: STAR Setting an EVAL scope, savestack=3 1 | 9: REF1 failed... REG_ANY can match 1 times out of 1... 2 | 9: REF1 failed... REG_ANY can match 1 times out of 1... 3 | 9: REF1 4 | 11: END Match successful! Freeing REx: `(.).*?\1'