% perl $raw = 'this/is/a/test'; $b = 'is/a'; $c = 'was/a'; $raw =~ s/$b/$c/g; print $raw, $/; # this/was/a/test