rschupp / PAR-Packer

(perl) Generate stand-alone executables, perl scripts and PAR files https://metacpan.org/pod/PAR::Packer
Other
48 stars 13 forks source link

get error when use pp with -A option #17

Closed sincos2007 closed 5 years ago

sincos2007 commented 5 years ago

command:

pp -o test -A addlist.txt test1.pl content in addlist.txt:

lib_3.pm lib

there are lib_1.pm and lib_2.pm under folder lib test1.pl call functions defined in lib_1.pm and lib_2.pm and lib_3.pm

after I run the command above, I get error:

for packingin/pp: cannot find file or directory lib_3.pm for packingin/pp: cannot find file or directory lib

Although I get the error, the output file from pp can print correct output. Who can tell me why?

rschupp commented 5 years ago
sincos2007 commented 5 years ago

Do you mean that use option -I to specify folder containing modules my perl script use and then these modules would be packed into result package?

sincos2007 commented 5 years ago

Well, I found reason of this issue. I open addlist.txt by gedit and choose menu File/Save As, then set EndOfLine to Unix/Linux, click Save button. The error gone when I run pp with -A option.

rschupp commented 5 years ago

Do you mean that use option -I to specify folder containing modules my perl script use and then these modules would be packed into result package?

Correct. If test.pl has use lib_1; (which lives in lib) how do you run test.pl? You would run perl -Ilib test.pl. Or maybe test.pl has additionally use lib "lib"? Then no additional options for pp are necessary.

Well, I found reason of this issue. I open addlist.txt by gedit and choose menu File/Save As, then set EndOfLine to Unix/Linux, click Save button. The error gone when I run pp with -A option.

Yeah, a file specified with -A should have the "native" end-of-lines for your OS - we're at the mercy of perl here, simply doing

while (<$fh>) 
{
    chomp;
    # add $_ to list of files to be added
}

If addlist.txt has CR-LF line endings, then chomp would leave a CR at the end of $_, that would explain the odd formatting of the error message.

shawnlaffan commented 5 years ago

It's an uncommon case, but one could convert the chomp to s/[\r\n]$//.

I frequently use that idiom to allow for files edited on windows but run under linux.

rschupp commented 5 years ago

Huh, doesn't work for me:

perl -E 'use Data::Dumper; $Data::Dumper::Useqq=1; 
            while (<>) { my $o = $_;  s/[\r\n]$//; say Dumper({$o => $_}) }' crlf.txt 
$VAR1 = {
          "CRLF\r\n" => "CRLF\n"
        };
$VAR1 = {
          "LF\n" => "LF"
        };

What about opening the file in :crlf mode (on either OS), then simply chomp the lines?

shawnlaffan commented 5 years ago

I should have tested the code. It needs a quantifier.

s/[\r\n]+$//

I haven't used the :crlf approach myself, but it could also work.