How do I get perl to recognize the special variable in the $replace string?$string = "firstword secondword"; print "original: $string\n"; # doesn't work $search = '(second.+)'; $replace = '$1 thirdword'; ($varsub = $string) =~ s/$search/$replace/; print "variable substitution: $varsub\n"; # does work ($direct = $string) =~ s/(second.+)/$1 thirdword/; print "direct: $direct\n";
Steve
In reply to Regexp variable substitution of special variable by cormanaz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |