Rudif has asked for the wisdom of the Perl Monks concerning the following question:
It turns out that the problem is related to the recently added regex feature, mentioned briefly in perlre like so#! perl -w use strict; # 1: no problem (even on Win32) # my $root = 'C:/perl'; my $podfile = 'C:/Perl/lib/Config.pm'; print "$podfile $root $1 $2\n" if $podfile =~ m!$root/(.*)/(\w+) +\.p.+$!i; # 2: causes error # my $rootb = 'C:\perl'; my $podfileb = 'C:\Perl\lib\Config.pm'; print "$podfileb $rootb $1 $2\n" if $podfileb =~ m!$rootb/(.*)/( +\w+)\.p.+$!i; # 3: simplified, causes error # print "yo\n" if 'perl' =~ m|\perl|; __END__
Apparently, m|\perl| means: match a property named 'e' which might be defined in a script or in the main module - but it is not defined, in my case.In addition, Perl defines the following: ... \pP Match P, named property. Use \p{Prop} for longer names. \PP Match non-P
The workaround is to replace backslashes by slashes before using such paths in a matching operationprint "==$Config{installprefix}==\n"; # prints ==C:\Perl==
However, if a path containing backslashes is being passed between code inside a module, you might have to dig deeply if you want to fix it.$podfileb =~ s!\\!/!g; $rootb =~ s!\\!/!g;
|
|---|