Similar to [this](https://stackoverflow.com/questions/6805028/how-to-replace-backward-slash-to-forward-slash-using-java), how do I achieve the same in Perl?

I want to convert:

```
C:\Dir1\SubDir1\` to `C:/Dir1/SubDir1/

```

I am trying to follow examples given [here](http://www.htmlite.com/perl025c.php), but when I say something like:

```
my $replacedString= ~s/$dir/"/"; # $dir is C:\Dir1\SubDir1\

```

I get a compilation error. I've tried escaping the `/`, but I then get other compiler errors.