When trying to use this module in the following manner, I found a bug.
use Proc::Background;
my $process = Proc::Background->new("Z:/Software/Perl/5.8.8/bin/perl.exe
-e \"use Text::CSV;\"");
Actually, the Perl script I really wanted to run in the background
process is more complicated than that, but this gives the source of the
problem.
That code generates this error (re-formatted to improve readability):
Can't locate Text/CSV.pm in @INC
@INC contains:
Z:/Software/Perl/58261E~1.8/site/lib
Z:/Software/Perl/58261E~1.8/lib
.
I found the source of the problem. Line 68 in Proc::Background::Win32 says:
$args[0] = Win32::GetShortPathName($args[0]);
This line causes the path to Perl.exe to change from
Z:/Software/Perl/5.8.8/bin/perl.exe
to
Z:/Software/Perl/58261E~1.8/bin/perl.exe
While that is the correct "short path name" to that perl.exe, it causes
Perl to behave VERY badly, including the corruption of @INC as shown
above. I don't believe Perl is expecting to be called in such a manner.
OK, maybe this is really a problem with Perl itself, but it can be fixed
in this module by modifying line 68 to:
if ($args[0] =~ m/ /) { $args[0] = Win32::GetShortPathName($args[0]); }
This insures GetShortPathName() is only called when needed to fix paths
with spaces in it, as the preceding lines in the module indicate.
There might be other ways to fix this too, like only calling
GetShortPathName() if perl.exe is not part of $args[0], since this could
be only an issue with perl.exe.
Hopefully this helps someone else who runs into this!