<joke>
    If you just need to hide the source from people reading it, why not look into Acme::EyeDrops or something? :)
</joke>

As for solutions, I don't think there are any better ways than those you have tried. Compiling any script-type (or interpreted) language that isn't intended to be made into binaries has always had these problems, as far as I can tell. I even remember there being BASIC to machine code compilers for the good old Commodore 64, and those had the exact same problem.

I think the basic problem is that you have a language that is (more or less, I know it isn't really true) interpreted on the fly, with the commands in the program being "references" to built-in functions in the interpreter, which are called and something happens. This is very hard to translate into effecient c or assembler code, usually the realistic approach is to either embed the whole interpreter and still call the same things, or replace each call with the corresponding function from the interpreter. Needless to say, this isn't gonna be very optimized - but at the same time, code that wasn't meant to be compiled is very hard to guess the optimized intention of.

As mentioned in perlrun, you have the -u option, and could use the undump program, but according to the example, that gets just as bloated, or worse. It is also very much deprecated in favour of the c-compiler alternatives you have already tried.

In short, if you need to hide your code for some reason, perl might not be the right tool for you. It is constructed with quite the opposite intentions, and it shows. On the other hand, if this is a special ocassion, is 20MB really that much? If it is just this program, this one time, just go for it if it works. It might feel silly to have 20MB worth of program printing "Hello world", but if it does the job... disk is cheap. :)

Also have a look at Can I get compiled code in Perl like in Java(class file), I seem to recall some good and related answers there.


You have moved into a dark place.
It is pitch black. You are likely to be eaten by a grue.

In reply to Re: Compiling Perl by Dog and Pony
in thread Compiling Perl by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.