PDA

View Full Version : [SOLVED] Perl packager--@INC when bundling multifile project



ceclauson
July 6th, 2011, 01:43 AM
Hello. I'm trying to use the Perl packager (pp) utility to bundle a multifile project into an executable, but when I try to run the resulting executable, it complains about not being able to find dependent files in @INC

Here are my files
mymain.pl:


#!/usr/bin/perl

#file main.pl

use strict;
use warnings;

require 'aux.pl';

my $mssg = get_mssg();

print $mssg;
print "\n";


aux.pl:



#file aux.pl

use strict;
use warnings;

sub get_mssg() {
return "Hello, there";
}

1;


Here's what happens at the command line:


cclauson@grendel:~/Desktop/perltest$ pp mymain.pl aux.pl -o mymain
cclauson@grendel:~/Desktop/perltest$ ./mymain
Can't locate aux.pl in @INC (@INC contains: /tmp/par-cclauson/cache-9e568f1d1f2ce9e2aa87d9efcf609800325cad51/inc/lib /tmp/par-cclauson/cache-9e568f1d1f2ce9e2aa87d9efcf609800325cad51/inc CODE(0x2beab98) CODE(0x2beb018)) at script/mymain.pl line 8.


Any help would be appreciated. Thanks in advance.

slavik
July 7th, 2011, 06:24 AM
1. modules are usually named with .pm in the end.
2. learn about "use lib"
3. you module code is terribad (no package declaration?)
4. learn about Module::Pluggable (you might not need it, but useful to know)

ceclauson
July 8th, 2011, 10:42 AM
Thanks for the reply, but still no luck.

new aux.pm:


#file aux.pm

use strict;
use warnings;

package aux;

sub get_mssg() {
return "Hello, there";
}

1;



new main.pl:



#!/usr/bin/perl

#file mymain.pl

use strict;
use warnings;

use lib '.';

require 'aux.pm';

my $mssg = aux::get_mssg();

print $mssg;
print "\n";



result:



% pp aux.pm mymain.pl -o mymain
% ./mymain
Can't locate aux.pl in @INC (@INC contains: CODE(0x167cae0) /tmp/par-cclauson/cache-215f58808ba7a9121e5f8dce734e5213cbfee5ab/inc/lib /tmp/par-cclauson/cache-215f58808ba7a9121e5f8dce734e5213cbfee5ab/inc CODE(0x1496ba8) CODE(0x1497028)) at script/mymain.pl line 10.

ceclauson
July 22nd, 2011, 06:41 AM
I figured it out. The correct command is:



% pp -M aux mymain.pl -o mymain