in reply to Using scalar variables as substitution regular expression

or maybe this would be easier:
$_ = "master442arb_ba"; $_ =~ /master(.*)arb_ba/; $action = "m$1a_ba"; s/$_/$action/; print $_;

Replies are listed 'Best First'.
Re^2: Using scalar variables as substitution regular expression
by almut (Canon) on Apr 05, 2009 at 09:44 UTC

    ... in which case you don't need the substition at all :)

    $_ = "master442arb_ba"; $_ =~ /master(.*)arb_ba/; $_ = "m$1a_ba"; print $_; # m442a_ba

    (the s/$_/$action/ in your snippet looks for "master442arb_ba" in "master442arb_ba" and replaces this (i.e. itself) with "m442a_ba" — an assignment is shorter...)