Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

packaging perl

by Jocqui (Novice)
on Jun 19, 2014 at 10:01 UTC ( [id://1090435]=perlquestion: print w/replies, xml ) Need Help??

Jocqui has asked for the wisdom of the Perl Monks concerning the following question:

I have a large perl project that i have split up into one main .pl file and multiple .pm files that are being referenced by the main .pl file . I wish to package everything into one file .I used to use "Perl Packager " so that i can have only one executable to send to multiple machines. However pp doesnt locate the .pm files and only packages the pl and other installed perl modules it references . Is there another method of providing this functionality?

Here is an example of the code i am using in the start.pl

#!/usr/bin/perl use strict; use warnings; use Time::HiRes qw(usleep); require moduleA; require moduleB; &moduleA::functionA(); &moduleB::functionA(); &moduleB::functionB(); __END__

and the perl moduleA

package moduleA; use strict; use warnings; require Expect; require Time::HiRes; require moduleB; use Time::HiRes qw(usleep); sub functionA() { my variableA ="&moduleB::functionB"; .............. ................ return someihng; }

When using pp pp start.pl -I ModuleA.pm ModuleB.pm -o start

Replies are listed 'Best First'.
Re: packaging perl
by dasgar (Priest) on Jun 19, 2014 at 13:38 UTC

    When using pp, I'm now in the habit of using the -c and -x options so that it can pick up on the needed modules. That should get pp to pick up your "other installed perl modules". If after that pp is still not picking up your .pm files, you can use the -I option to specify an additional path for pp to look in for modules and if you need to, you can use this option multiple times.

    Although I personally haven't used this module myself, you could also use App::FatPacker to pack all of the modules that your script uses (including your .pm files) along with your script into one large .pl file. Then you can use pp to package that large .pl file into an executable.

      have tried App::Fatpacker but due to the fact that the pm files are interliinked and arent referenced directly by pl it doesnt pick them up. i will try it with pp again and let you know, Thanks

      Unfortunately cant seem to get pp to work .The pm packages are ones i have created for the purpose of reusing my code so for example if want to use a function between modules in perlmodulea i have to require perlmoduleb &perlmoduleb::function so using pp -I will package everything but when i exacute it i get Can't locate modulea.pm in @INC (@INC contains: /tmp/par-root/cache-e4edf49bbe31d9e1cba71594a8c68a0e6090d909/inc/lib /tmp/par-root/cache-e4edf49bbe31d9e1cba71594a8c68a0e6090d909/inc CODE(0x241dd30) CODE(0x241e1b0)) at script/test.pl line 7.

        "I have a large perl project that i have split up into one main .pl file and multiple .pm files that are being referenced by the main .pl file . I wish to package everything into one file "

        When you say you split up the large project, this begs the question if the large project was one file to begin with. If so, why do you want to put the pieces back into one large file again?

        Why not instead do what CPAN authors do? A CPAN module is one TAR BALL. Then you use standard Perl tools to install that module. I recommend that you download Module::Starter and use it to build the skeleton framework that will house your custom Perl code and use something like Module::Build to install it.

        jeffa

        L-LL-L--L-LL-L--L-LL-L--
        -R--R-RR-R--R-RR-R--R-RR
        B--B--B--B--B--B--B--B--
        H---H---H---H---H---H---
        (the triplet paradiddle with high-hat)
        

        Can you provide the following information?

        • Names and full paths to the .pl script and .pm files that you wrote and are trying to use
        • The use and require statement lines from your .pl script.
        • The full command you're using to call pp (including all option arguments for pp).

        If you can provide this information, that could help others figure out what's happening and how to fix it.

Re: packaging perl
by Anonymous Monk on Jun 19, 2014 at 10:05 UTC

    "pp -Perl Packager "

    Why are you using -Perl option? What do you think that does?

    You want to use  pp -x -l libgif... foo.pl ...

      i am mentioning the method i was using perl packager. not giving a sample of the code i was using

        i am mentioning the method i was using perl packager. not giving a sample of the code i was using

        That is very weird since that isn't a valid method :)

        Unknown option: Perl pp: Input file Packager was not found

        pp is what you need to use ... its very simple to use , and will find all .pm files your program use/require, especially if you use the -x option ... and you can even tell it manually which files to add in the rare case they aren't detected by -x

        If you post a small stub program and few small stub modules, and your pp invocation, I'll help you work it out

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-24 11:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found