Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: What can we assume in a BEGIN block ?

by leriksen (Curate)
on Oct 04, 2004 at 11:34 UTC ( #396193=note: print w/ replies, xml ) Need Help??


in reply to Re^2: What can we assume in a BEGIN block ?
in thread What can we assume in a BEGIN block ?

OK, so now I know I really dont get it.

What variable got incremented at compile time ? If the "our $initialised" doesnt happen till run-time, what did we increment during the BEGIN?

use brain;


Comment on Re^3: What can we assume in a BEGIN block ?
Re^4: What can we assume in a BEGIN block ?
by diotalevi (Canon) on Oct 04, 2004 at 13:40 UTC

    The variable $initialized was declared by the my $initialized. This made it known the parser so when the source code farther down saw it, it incremented the variable. At the time, the value was still undefined because while the variable had been declared, the = 0; hadn't run yet. So now $variable = 1 after the BEGIN. Now that the file is finished being parsed, execution starts at the top so now you run $initialized = 0;.

    $variable := undef -> 1 -> 0

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://396193]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2014-09-02 05:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (20 votes), past polls