in reply to backreference followed by literal in regex substitution

You can separate a variable name from following alphanumerics using curly brackets, a la:

#!/usr/bin/perl use strict; use warnings; $_ = q{some search criteria}; s/(s)(o)(m)(e)( )search criteria/$1$2${3}2010$4$5/g; print;

See Regexp Quote Like Operators for details on regular expression interpolation.

Replies are listed 'Best First'.
Re^2: backreference followed by literal in regex substitution
by jayw (Initiate) on Jan 05, 2010 at 18:39 UTC

    Perfect. And Thanks! jw