Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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

by leriksen (Curate)
on Oct 05, 2004 at 00:05 UTC ( #396438=note: print w/replies, xml ) Need Help??


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

Yep, I think my main problem was understanding what 'parse' meant.

Discussion below uses this code

our $initialised = 0; BEGIN { _initialise(); $initialised = 1; }

Initially (when I didnt understand the problem) I thought the bare (not in a BEGIN) our $initialised = 0; meant 'found a scalar declaration, allocate memory, create an entry in the symbol table that references that location,and put a 0 in that memory location. Now parse and run the BEGIN block, which will result in $initialised having a 1 in it'.

Now I (think/know) it means 'found a scalar declaration, allocate memory, create an entry in the symbol table that references that location,and generate some opcodes that will result in a 0 being put in that location at runtime.Now parse and run the BEGIN block, which will result in $initialised having a 1 in it, which will get clobbered back to 0 by the opcodes at runtime'

Thanx merlyn for taking the time to break this down for me. I hope I have it straight now.

use brain;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://396438]
help
Chatterbox?
[msh210]: I think I just found a lie in perldoc.
[msh210]: warn: "If the last element of LIST does not end in a newline, it appends the same file/line number text as die does."
[msh210]: perl -e'warn "test$/", "" '
[msh210]: doesn't append anything.
[msh210]: It should say "If the last nonempty element of LIST" or "If the string thus to be printed does not end in a newline""

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2017-04-24 12:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (439 votes). Check out past polls.