There's another reason why this path is not really worth taking. There is no clear and set "compile time" and "execution time" with Perl. When you start a Perl program it's not first all compiled, including all modules, but instead a bit is compiled from the script, a bit from the module it uses, a bit from the module that module uses, then the code that's outside subroutines in that second module gets executed, then the import() subroutine of that module gets executed (if present), then perl returns to compiling the first module, compiles&executes some more modules, finaly finishes compiling the module, executes it's top-level code and import(), compiles a bit from the script ....

And I did not even mention BEGIN{} blocks that are executed as soon as fully compiled, before the stuff that follows gets compiled.

And the already compiled and/or executed code can affect how is compiled (even parsed!) the rest of the code:

V:\>perl -MO=Deparse -e "$x = FOO + 7 + 9" $x = 'FOO' + 7 + 9; -e syntax OK V:\>perl -MO=Deparse -e "use constant FOO => 8; $x = FOO + 7 + 9" use constant ('FOO', 8); $x = 24; -e syntax OK
or
V:\>perl -MO=Deparse -e "sub foo {}; sub bar {};$x = bar foo 7, 9" sub foo { } sub bar { } $x = bar(foo(7, 9)); -e syntax OK V:\>perl -MO=Deparse -e "sub foo ($) {}; sub bar {};$x = bar foo 7, 9" sub foo ($) { } sub bar { } $x = bar(foo(7), 9); -e syntax OK

And some modules need to check the availability of some other modules or libraries (DLLs or whatever) and will decide based on that info what other module to load or which version of the code to actually compile.

So it's not just "OK, at this point everything is compiled and we can save the current state to disk and next time (on a different compute) just load it and run".


In reply to Re^6: perl language by Jenda
in thread perl language by hashin_p

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.