Hi, This is how I'd do it:
$data = "[03/12/2002:14:19:50]"; # to become: '2002-03-12 14:19:50' $match = '\[(\d\d)\/(\d\d)\/(\d{4}):(\d\d):(\d\d):(\d\d)\]'; if ( $data =~ /$match/){ $replace = "$3-$1-$2 $4:$5:$6"; # do variable subs explicitly after the pattern match $data =~ s/$match/$replace/e; print $data, " replaced!\n"; }else{ print $data, " failed to replace.\n"; } Of course, I'm sure TIMTOWTDI... Incidentally, I strongly recommend visiting www.perlmonks.org. This stuff is bread-and-butter to them :-) Tim "Bruce A. Burdick, Jr." wrote: > Anyone have any idea how this might be accomplished? : > > For a normalization scheme, I have match and replace strings stored in > variables (because they vary, of course) brought in from XML files. The > replace strings depend on what is found in the match string. The problem? > The replacement string is taken literally no matter what variations I've > tried. Some examples: > > $data = '[03/12/2002:14:19:50]'; # to become: '2002-03-12 14:19:50' > $match = '\[(\d\d)\/(\d\d)\/(\d{4}):(\d\d):(\d\d):(\d\d)\]'; > $replace = '\3-\1-\2 \4:\5:\6'; > > unless ( $data =~ s/$match/$replace/ ) > { > print $data, " failed to replace.\n"; > } > else > { > print $data, " replaced!\n"; > } > > This yields: > > \3-\1-\2 \4:\5:\6 replaced! > > Not exactly what I'm looking for. > > I've tried: > > $replace = '$3-$1-$2 $4:$5:$6'; > > Doesn't work. I've tried it with double-quotes. I've wrapped eval around it > several different ways. I've tried the 'e' option and the 'x' option on the > s/// operator. qr// is only for match strings, it seems. I'm stumped. > > I'll have a lot of different replacement strings stored in the schema data > -- a growing collection. So hard-coding them is the last option. > > Am I overlooking something simple? > > -B...