Instead of escaping slashes, use a different delimiter:

```perl
if ($loc =~ m{^/dev/}) {
```