I'm not altogether sure if I've got the right forum for this, but I'm sure one of the janitors will point me/it in the right direction if it looks a little lost;-)
Any road up, my problem now is the oft-quoted equivalent of the use statement, being approximated to...
Consider the trivial example of module:BEGIN { require module; module->import(); }
and script:package Test1; CHECK { warn "Test1::CHECK1 running" } INIT { warn "Test1::INIT1 running" } UNITCHECK { warn "Test1::UNITCHECK1 running" } sub method { warn "method()" } 1;
When run, the trivial test script produces the following, expected, output...use Test1; Test1->method();
Now, compare and contrast that with changing the script - to..Test1::UNITCHECK1 running at Test1.pm line 7. Test1::CHECK1 running at Test1.pm line 3. Test1::INIT1 running at Test1.pm line 5. method() at Test1.pm line 9.
When run, this results in the following, not so expected, output...require Test1; Test1->method();
Given that perldoc asserts thatTest1::UNITCHECK1 running at Test1.pm line 7. method() at Test1.pm line 9.
CHECK code blocks are run just after the initial Perl compile phase ends and before the run time begins, in LIFO orderi.e. it makes no mention of this seemingly 'special' behaviour meted out to required modules, am I, yet again, missing something obvious or are the 2 not equivalent in as much as CHECK & INIT blocks in the module are, seemingly, only ever executed if the module is used i.e. they never get executed if the module is only required.
.oO(If I am, just for once, right, is there a case for an appropriate update to perlmod ???)
In reply to use equivalent ? I suspect not... by Bloodnok
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |