my $repl = '$1'; eval <<"EOT"; while (1) { \$str =~ s/([a-z]),/$repl/g; } EOT