On 2/4/2004 10:52 AM, [EMAIL PROTECTED] wrote:

I'm new to PERL and am trying to learn by reading some PERL programs.

My question is this - does PERL execute sequentially and "skip around"
embedded subroutines or
Does it execute them inline?

In depth answer:


perl reads in your source file and parses the code from top to bottom. If it sees a 'use <module>;' statement it stops parsing your file, reads and parses the used module, and then resumes parsing your source. If it encounters any 'BEGIN' subs (there can be more than one), it executes the code in that sub as soon as the complete sub has been completely parsed, but before parsing the remainder of your source. After the source has been parsed, perl executes any 'CHECK' subs (there can be more than one) beginning with the last, continuing in the *reverse* order of definition. If you specify the '-c' (compile-only) switch, the process ends here. Otherwise perl continues execution at the top first with the execution of any 'INIT' subs in the order they are defined. Then perl begins executing any code at file scope, executing code in subroutines only when (or if) they are called. Afterwards, perl executes any 'END' subs in reverse order of definition.

Randy.



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to