my $c = 'aaabbbaaa'; my $d = 's/b/c/g'; eval "\$c =~ $d"; die "Failure: $@\n" if $@; print $c, "\n";