develooper Front page | perl.perl6.users | Postings from August 2022

Re: BEGIN {} question

Thread Previous | Thread Next
ToddAndMargo via perl6-users
August 29, 2022 15:29
Re: BEGIN {} question
Message ID:
On 8/29/22 00:44, Elizabeth Mattijsen wrote:
>> Question, would BEGIN go at the top or the bottom
>> of my code?  Seems the compiler would hit it first
>> at the top, but I do not know if it makes a full
>> pass of everything before firing off the BEGIN.
> BEGIN runs at *compile* time.
> This means that anything before the BEGIN statement in the code, is compiled and known and can be referenced in the BEGIN block.
> Anything *after* the BEGIN statement is still unknown to the compiler and can therefore *not* be referenced.
> Liz

Hi Liz,

Excellent explanation.  Thank you!

Does the compiler make a full pass through
the code before firing off the BEGIN routine
or does it fire it off as soon as it finds it?


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About