Closed sincos2007 closed 5 years ago
-A
is not the correct way to include additional perl modules, it's for stuff like data filestest.pl
just use
s (or require
s) lib_1
etc, then these should have been packed automagically - perhaps after adding -I lib
(and -I .
on very recent versions of perl), the same options you would need to run test.pl
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?
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.
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.
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.
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?
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.
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?