Subject: | cargo-culted use of /xms regex flags |
The C:P:S:S code uses the /xms regex flags all over the place, apparently without understanding why. For reference:
- /x allows whitespace and comments in the regex. This feature is never used.
This doesn't cause any real problems (besides code readability) but it shows the author probably didn't know what they were doing.
- /m makes ^ and $ match at the beginning/end of embedded lines (that is, around newlines contained in the string).
This is not what the code expects:
if ( $dir =~ m{^qr/}xms )
if ( $path =~ /.*\.(\S{1,})$/xms ) {
$dir =~ s/(\/|\\)$//xms;
...
These are all written as if $ only matched at the end of the string.
- /s makes . match all characters, including newline.
This doesn't cause any problems because the only use of . is as a leading /.*rest-of-regex/ in regexes, which has no effect (the * allows 0 matches so it's 100% redundant anyway).