P is for Practical PerlMonks

### PP: Executables still need require files.....

by gepebril69 (Beadle)
 on Jul 20, 2012 at 13:31 UTC ( #982825=perlquestion: print w/ replies, xml ) Need Help??
gepebril69 has asked for the wisdom of the Perl Monks concerning the following question:

Hi there,

I'm working with Perl a few years now and thanks to pp I manage to get executables instead of scripts. However I use 2 pl files to store defines and basic functions like this:

require File::HomeDir->my_home."\\software\\scripts\\basic_func.pl";
require File::HomeDir->my_home."\\software\\scripts\\defines.pl";
[download]

If I remove these files after I created executables I still need these files at runtime :S

call pp -o fill_usb_stick.exe -x -c -vvv <code>fill_usb_stick.pl

What am I doing wrong, or do I need to take a different approach?

Yours sincerely.

Comment on PP: Executables still need require files.....
Select or Download Code
Re: PP: Executables still need require files.....
by zentara (Archbishop) on Jul 20, 2012 at 13:37 UTC
do I need to take a different approach?

How about just installing Perl on the target machines, and give them a script? :-) TGIF

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh
Re: PP: Executables still need require files.....
by dasgar (Deacon) on Jul 20, 2012 at 13:53 UTC

Here's what I would try. Put all 3 .pl files in the same directory. Modify your require calls to be:

require basic_func.pl;
require defines.pl;
[download]

With your same call to pp to build the .exe file, I think that this should pick up the two other .pl files, but I have not tested this myself.

Re: PP: Executables still need require files.....
by marto (Chancellor) on Jul 20, 2012 at 14:32 UTC

I can't think of a sensible way to get this to work with the File::HomeDir module. Perhaps it would be better if you took a slightly different approach and had your required files in a sub directory of your main script, for example:

pptest.pl:

#!/usr/bin/perl

use strict;
use warnings;

require "tmpinc\\foo.pl";
require "tmpinc\\bar.pl";
[download]

tmpinc\foo.pl:

#!/usr/bin/perl

print "in foo.pl\n";
[download]

tmpinc\bar.pl:

#!/usr/bin/perl

print "in bar.pl\n";
[download]

packaging with a command similar to you:

c:\pp -o pptest.exe -x -c pptest.pl
[download]

and running the resulting executable shows:

C:\>pptest.exe
in foo.pl
in bar.pl
[download]
Ok,

I will give it a try, was using this File::HomeDir as I was developing on two different servers.

It worked!!!!

Thanks very much!

Re: PP: Executables still need require files.....
by CountZero (Chancellor) on Jul 20, 2012 at 14:51 UTC
You can always use the -a or --addfile argument to force pp to include files it might otherwise miss.

However, there is no guarantee that the home directory on your system is the same on other systems. I do not think pp is bright enough to find out where it has to drop these files. Much better to keep them in the same directory as your main script.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics

Log In?
 Username: Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://982825]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2014-03-14 00:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?