Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^4: Use of uninitialised value... but it is defined ?!

by Discipulus (Canon)
on Mar 02, 2016 at 08:33 UTC ( [id://1156627]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Use of uninitialised value... but it is defined ?!
in thread Use of uninitialised value... but it is defined ?!

BrowserUk: exactly, the order matter. the slot for the variable is created (no errors for undeclared variables) but the assignement not yet. BEGIN blocks jump directly in runtime during the compilation of the program. Quite a good feature!

Consider the output of the following snippet: perl -wE "my $time = time; BEGIN{say time; sleep 5}; say $time"

PS the above behaves the same with lexical and package vars:

perl -E "$time = time; BEGIN{say time; sleep 5}; say $time"

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (6)
As of 2024-03-28 18:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found