Windows paths


Windows paths are… different.

I’m in the process of producing a new release of Data::Resolver and I hit a small roadblock:

Data::Resolver matrix for version 0.003001

Fate decided to have some fun and prevented me from reading the reports, but folks at CPAN Testers saved the day once again:

CPAN Testers tweet exchange

It eventually landed me on the error:

#                   'C:\DOKUME~1\smoker\LOKALE~1\Temp\CV48qkF3Z_\foo'
#     doesn't match '(?^u:(?mxs:(?mxs: \A | /) foo \z))'

Silly me! Paths in Windows use a different path separator, so my regular expression was wrong checking whether the bare file name was alone or preceded by the Unix path separator.

No big deal, I decided to use File::Basename’s basename to strip the directory part and turn a like test into an exact one.

So here’s your lesson, future me: always use File::Spec, its ecosystem or other proven modules to mess with paths in the local filesystem, if you value portability!

Stay safe and portable!

Comments? Octodon, Twitter, GitHub, Reddit, or drop me a line!