Subject: | Makefile.PL generates bad Devel::Cover::Inc.pm on Windows (with patch) |
If I invoke 'perl Makefie.PL' on Windows using an absolete UNC path to
perl.exe (if I have the UNC path to the perl installation in my PATH),
then when Makefile.PL writes this into Inc.pm:
our \$Perl = '$^X';
the resulting Inc.pm has this:
our $Perl = '\\server\path\to\perl-5.8.8\bin\perl.exe';
And when Inc.pm is used (for instance, when attempting to run the
Devel::Cover tests, the value of $Perl is...
DB<3> p $Devel::Cover::Inc::Perl
\server\path\to\perl-5.8.8\bin\perl.exe
That's because \\ inside single quotes is really stripped. Ref: see
'perldoc perlop' under 'Gory details of parsing quoted constructs' in
the section 'Interpolation':
'', "q//"
The only interpolation is removal of "\" from pairs "\\".
Inc.pm really needs to have any backslashes doubled:
our $Perl = '\\\\server\\path\\to\\perl-5.8.8\\bin\\perl.exe';
OR the value should be set with <<'EOF', which doesn't remove \:
chomp(our $Perl = <<'EOF');
\\server\path\to\perl-5.8.8\bin\perl.exe
EOF
The best way to double the backslashes is to use Data::Dumper. You
could just use s'\\'\\\\'g before printing the value surrounded by ',
but that doesn't help you in the general case of weird pathnames (i.e.,
it might have ' in it!)
The three possible patches for Makefile.PL are:
diff -U1 Makefile.PL.orig Makefile.PL.fix1
--- Makefile.PL.orig 2006-12-19 08:25:50.000000000 -0500
+++ Makefile.PL.fix1 2006-12-19 08:25:50.000000000 -0500
@@ -56,3 +56,5 @@
our \$VERSION = "$Version";
-our \$Perl = '$^X';
+chomp(our \$Perl = <<'EOF');
+$^X
+EOF
our \$Perl_version = '$]';
diff -U1 Makefile.PL.orig Makefile.PL.fix2
--- Makefile.PL.orig 2006-12-19 08:25:50.000000000 -0500
+++ Makefile.PL.fix2 2006-12-19 08:25:50.000000000 -0500
@@ -38,2 +38,4 @@
+(my $Perl = $^X) =~ s/\\/\\\\/g;
+
open I, ">lib/Devel/Cover/Inc.pm"
@@ -56,3 +58,3 @@
our \$VERSION = "$Version";
-our \$Perl = '$^X';
+our \$Perl = '$Perl';
our \$Perl_version = '$]';
diff -U1 Makefile.PL.orig Makefile.PL.fix3
--- Makefile.PL.orig 2006-12-19 08:25:50.000000000 -0500
+++ Makefile.PL.fix3 2006-12-19 08:25:50.000000000 -0500
@@ -19,2 +19,4 @@
+use Data::Dumper;
+
$| = 1;
@@ -38,2 +40,8 @@
+my $Perl;
+{
+ local $Data::Dumper::Terse = 1;
+ $Perl = Dumper($^X);
+};
+
open I, ">lib/Devel/Cover/Inc.pm"
@@ -56,3 +64,3 @@
our \$VERSION = "$Version";
-our \$Perl = '$^X';
+our \$Perl = '$Perl';
our \$Perl_version = '$]';
Thank you!