Hi Bernd,
sorry for answering your ticket in the PAR queue this late. Back when
you created it in 2005, I wasn't even the PAR maintainer.
I have had a look at the problem. When opening a scalar reference for
writing to the scalar, the core open() adds a PerlIO layer to the file
handle. The layer is ':scalar'. That layer is implemented in
PerlIO::scalar. Of course, the dependency scanner of PAR (which is
Module::ScanDeps) has absolutely no way of determining that using a
static code scan. Unfortunately, most programmers wouldn't know either.
(I didn't before I asked some core developers and read some docs.)
Hence, the program works as an .exe if you do this:
pp -o t.exe -M PerlIO -M PerlIO::scalar t.pl
Now, I know this sucks. It's a combination of various shortcomings that
makes it so problematic.
a) Module::ScanDeps doesn't pick up the dependency on PerlIO. It could
possibly scan for strings like "open FOO, '>:LAYER', ...' and load
PerlIO and PerlIO::LAYER if that's found. But that seems rather fragile
and wouldn't even fix *your* problem but just a related set of problems.
b) The core open() function magically adds the :scalar PerlIO layer if
the third argument to open() is a reference. There is no way to find out
whether it is a reference except by executing the code. Neither by
scanning statically nor using compile-time checks and PPI for parsing
the code.
c) The problem seems to be isolated to win32 which would make me guess
that PerlIO::scalar implementations differ on varuious platforms. I
haven't checked but I'm not going to either. It's a core Perl problem if
any.
I'll keep this ticket open. Perhaps one day, someone smarter will step
up and come up with an elegant fix. I doubt it, though.
Steffen
On Do. 20. Jan. 2005, 01:17:34, BDULFER wrote:
Show quoted text> System: Windows XP
> Activestate Perl 5.8.4
> PAR 0.85
>
> Script:
> ------------------------8<---------------------------
> use strict;
> use warnings;
>
> my $string = '';
>
> open STRING, '>', \($string);
>
> print STRING "Test PAR\n";
>
> close STRING;
>
> print '$string: ', $string;
> ------------------------8<---------------------------
>
> Running on Win XP produces the desired output:
> $string: Test PAR
>
> Running the executable after compiling with:
>
> pp test_pp.pl
>
> produces the following error:
>
> Can't locate PerlIO.pm in @INC (@INC contains:
> D:\DOKUME~1\bdulfer\LOKALE~1\Temp\par-bdulfer\cache-
> e8d3b155155ed93259e4110acaa03a637684f12a/inc/lib
> D:\DOKUME~1\bdulfer\LOKALE~1\Temp\par-bdulfer\cache-
> e8d3b155155ed93259e4110acaa03a637684f12a/inc CODE(0xd3d780) .) at
> script/test_pp.pl line 6.
>
> After compiling with:
>
> pp test_pp.pl -o test_pp.exe -M PerlIO
>
> the executable runs, but the output is:
>
> $string:
>
>
> On Linux every compiled version runs like it should.
>
> rgds
>
> Bernd
>