Hi again, all you venerable monastery dwellers,

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...

BEGIN { require module; module->import(); }
Consider the trivial example of module:
package Test1; CHECK { warn "Test1::CHECK1 running" } INIT { warn "Test1::INIT1 running" } UNITCHECK { warn "Test1::UNITCHECK1 running" } sub method { warn "method()" } 1;
and script:
use Test1; Test1->method();
When run, the trivial test script produces the following, expected, output...
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.
Now, compare and contrast that with changing the script - to..
require Test1; Test1->method();
When run, this results in the following, not so expected, output...
Test1::UNITCHECK1 running at Test1.pm line 7. method() at Test1.pm line 9.
Given that perldoc asserts that
CHECK code blocks are run just after the initial Perl compile phase ends and before the run time begins, in LIFO order
i.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.
Moreover, if an hierarchy of modules each have CHECK &/or INIT blocks, the hierarchy of blocks is broken wheresoever one of the modules requires another.

.oO(If I am, just for once, right, is there a case for an appropriate update to perlmod ???)

A user level that continues to overstate my experience :-))

In reply to use equivalent ? I suspect not... by Bloodnok

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.