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

Greetings,

I am trying to create a simple distribution method that preserves the multi-platform'ness of Perl (AKA, i dont want to "Compile" it into native machine code via Perl2Exe).

Can i just combine all the scripts and the dependancies into one file ? With the "package" keywords, it should adjust the namespace, etc... but it seems there are issues with the "use X' or "require X' lines... or do i need them in this case ? Will it work at all ?

Any ideas anyone ?

-Lenny
  • Comment on Can i combine all the .PM's and main script into one file to create a distribution ?

Replies are listed 'Best First'.
Re: Can i combine all the .PM's and main script into one file to create a distribution ?
by Joost (Canon) on May 07, 2007 at 20:05 UTC
    In theory, with reasonably well-behaved modules, you can put all the code in the same file, provided you put all the modules in in the right order. Note that a use Module::Name arguments; statement also calls Module::Name->import( arguments ) so you'd have to replace the use statements with import() calls.

    There might be issues with modules that use tricks in BEGIN blocks, or rely on being called during a BEGIN block.

    As a side note, have you seen PAR?

Re: Can i combine all the .PM's and main script into one file to create a distribution ?
by blazar (Canon) on May 07, 2007 at 19:58 UTC

    You can use the code in @INC feature to put the code for all the modules in a single file. Also, I've "always" used PAR to create platform (i.e. Windoze) specific executables, but ISTR it has the capability of also doing exactly what you're after.

        For the lazy (it's a virtue right?) among us, the key node returned by the Super Search referred to above is RFC: feature proposal re code in @INC.

        Well, I'm not sure if that is the "key" node. Actually that's one of my favourite features and I'm confident that quite about anywhere I talked about "code" and @INC I was talking about code-in-@INC. Such is the case with that node, that in turn is highly speculative. OTOH in some of the other hits I may have included real code examples.