my $repl = '$1'; my $str = "a,A,c,d"; s/([a-z]),/$repl/eeg; # Note the double 'e' modifier say $str; __END__ aA,cd #### my $repl = '$1'; eval <<"EOT"; while (1) { \$str =~ s/([a-z]),/$repl/g; } EOT