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

Re: BEGIN {} question

Thread Previous | Thread Next
From:
ToddAndMargo via perl6-users
Date:
August 29, 2022 15:29
Subject:
Re: BEGIN {} question
Message ID:
d39b791d-6e01-bd5e-d92e-e07a69839aa6@zoho.com
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?

-T

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About