= ~ very different from =~ . The first is assignment and bitwise negation, the second is the binding operator used with regular expressions.
What you want is:
$string_to_change =~ s/pattern_to_look_for/string_to_replace_with/g;
Note the use of the global /g option to make changes to the entire line. In your case, it looks like you need:
$dir =~ s/\\/\//g;
If you want a more readable regular expression, you can exchange the delimiter: s#\\#/#g;
If you want to keep the original string, you can copy it before performing a replacement. You can also use transliteration: tr#\\#/# - in this case you do not need a global option.
In short:
$dir =~ tr
Documentation:
TLP
source share