#!/usr/bin/perl -- use warnings; use strict; use re 'debug'; my $chr = "this and that"; $chr =~ s/(this|that)|(\w+)/$1\U$2/g; #error reported print "$chr\n"; __END__ #### Compiling REx `(this|that)|(\w+)' size 19 Got 156 bytes for offset annotations. 1: BRANCH(12) 2: OPEN1(4) 4: BRANCH(7) 5: EXACT (10) 7: BRANCH(10) 8: EXACT (10) 10: CLOSE1(19) 12: BRANCH(19) 13: OPEN2(15) 15: PLUS(17) 16: ALNUM(0) 17: CLOSE2(19) 19: END(0) minlen 1 Offsets: [19] 0[0] 1[1] 0[0] 1[1] 2[4] 0[0] 6[1] 7[4] 0[0] 11[1] 0[0] 12[1] 13[1] 0[0] 16[1] 14[2] 17[1] 0[0] 18[0] Matching REx `(this|that)|(\w+)' against `this and that' Setting an EVAL scope, savestack=5 0 <> | 1: BRANCH Setting an EVAL scope, savestack=15 0 <> | 2: OPEN1 0 <> | 4: BRANCH Setting an EVAL scope, savestack=25 0 <> | 5: EXACT 4 < and tha> | 10: CLOSE1 4 < and tha> | 19: END Match successful! Matching REx `(this|that)|(\w+)' against ` and that' Setting an EVAL scope, savestack=25 4 < and tha> | 1: BRANCH Setting an EVAL scope, savestack=35 4 < and tha> | 2: OPEN1 4 < and tha> | 4: BRANCH Setting an EVAL scope, savestack=45 4 < and tha> | 5: EXACT failed... 4 < and tha> | 8: EXACT failed... Clearing an EVAL scope, savestack=35..45 4 < and tha> | 13: OPEN2 4 < and tha> | 15: PLUS ALNUM can match 0 times out of 2147483647... Setting an EVAL scope, savestack=35 failed... Clearing an EVAL scope, savestack=25..35 Setting an EVAL scope, savestack=25 5 | 1: BRANCH Setting an EVAL scope, savestack=35 5 | 2: OPEN1 5 | 4: BRANCH Setting an EVAL scope, savestack=45 5 | 5: EXACT failed... 5 | 8: EXACT failed... Clearing an EVAL scope, savestack=35..45 5 | 13: OPEN2 5 | 15: PLUS ALNUM can match 3 times out of 2147483647... Setting an EVAL scope, savestack=35 8 < that> | 17: CLOSE2 8 < that> | 19: END Match successful! Use of uninitialized value in concatenation (.) or string at 2 line 9. Matching REx `(this|that)|(\w+)' against ` that' Setting an EVAL scope, savestack=35 8 < that> | 1: BRANCH Setting an EVAL scope, savestack=45 8 < that> | 2: OPEN1 8 < that> | 4: BRANCH Setting an EVAL scope, savestack=55 8 < that> | 5: EXACT failed... 8 < that> | 8: EXACT failed... Clearing an EVAL scope, savestack=45..55 8 < that> | 13: OPEN2 8 < that> | 15: PLUS ALNUM can match 0 times out of 2147483647... Setting an EVAL scope, savestack=45 failed... Clearing an EVAL scope, savestack=35..45 Setting an EVAL scope, savestack=35 9 | 1: BRANCH Setting an EVAL scope, savestack=45 9 | 2: OPEN1 9 | 4: BRANCH Setting an EVAL scope, savestack=55 9 | 5: EXACT failed... 9 | 8: EXACT 13 <> | 10: CLOSE1 13 <> | 19: END Match successful! String too short [regexec_flags]... Match failed Freeing REx: `"(this|that)|(\\w+)"'