in reply to perl one liner

Do the assignment and substitute thereafter:

($var2 = $var1) =~ s!/!!;

The substitution above operates on $var2.