perlunicodepp-perl-par-packager

Perl: par packer executable with Unicode::GCString, Can't locate object method "new"


I'm using the PAR::Packer module to create a Windows executable of a Perl script that uses the Unicode::GCString module.

A stripped down version of the script is as follows:

mwe.pl

#!/usr/bin/env perl
use strict;
use warnings;
use Unicode::GCString;

my $gcs  = Unicode::GCString->new("hello world");
print $gcs->columns();

exit(0);

When I run

perl mwe.pl

the output gives the 'width' of the string:

11

which is as expected.

I create mwe.exe using the command

 pp -o mwe.exe mwe.pl

and when I run

 mwe.exe

I receive the error

Can't locate object method "new" via package "Unicode::GCString" at script/mwe.pl line 6

Having reviewed AppData\Local\Temp\par-xxxxxx\cache-xxxxx\inc\lib, I believe that Unicode::GCString is present, as is Unicode::LineBreak.

Does anyone have any ideas on how to fix this?


Solution

  • A solution can be to use this version of "pp" I call it "ppp.pl"

    $ENV{PAR_VERBATIM}=1;
    system 'pp', @ARGV;
    

    Details at https://metacpan.org/pod/distribution/PAR/lib/PAR/Environment.pod#PAR_VERBATIM

    The cause is related to this bug Bug #38271 for PAR-Packer: PodStrip does not strip "=encoding utf8" which cause the executable generated by pp failed to exec

    Also the boilerplate inside Unicode::GCString