1

I have a script that works fine when using Perl, but fails when I convert it to a .exe using PAR::Packer and run it (all this on Windows);

The issue only occurs when I store the encoding type to open a file in a variable. Example:

my $enc= "utf8";

open my $FH, "<:encoding( $enc )", $ARGV[0]
  or die "$!";

Assuming the file I give exists.... This code fails every time no matter which encoding type or variable type I use to store the encoding type. This only works if I hardcode the encoding in the open function (Ex: "<:encoding(utf8)" ). I get "No such file or directory" from $! when this fails.

How can this be? Not sure why this would fail when using PAR::Packer, but it works fine when I run it directly using Perl.

My workaround was to use binmode after the open function, but it is killing me not to know why the code above won't work.

I'm using Perl 5.30.2 on Windows 10. I'm also using the latest pp version.

Thank you

JohnnyLoo
  • 877
  • 1
  • 11
  • 22
  • I can confirm that the problem also occur on Ubuntu 19.10, perl 5.30. The error I get is: `Unknown PerlIO layer "encoding"`. There is no error if I run the script directly – Håkon Hægland Apr 16 '20 at 18:40
  • Maybe you need to force the inclusion of PerlIO::encoding? (Never used PAR::Packer, so I'm not sure that statement makes sense.) – ikegami Apr 16 '20 at 21:49

0 Answers0