This solution will not allow you to use modules (or do other compile time work) cleanly. Any use statement (no statement, BEGIN block, END block, etc.) will always get executed no matter how the enclosing module is used.
The previous method (__END__;#!perl + perl -x module.pm), while more cumbersome in some ways, lets you do compile time work as normal.
--DrWhy
"If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."
| [reply] [d/l] [select] |
Any use statement (no statement, BEGIN block, END block, etc.) will always get executed no matter how the enclosing module is used.
That is true, so I don't do that. I don't use the Test::* modules as they tell me what passed rather than what failed. I also have very definite ideas about the form that unit testing should take and that does not fit well with the pattern of a zillion ok()/not_ok() tests that those modules encourage.
If my test code needs additional modules, I require them not use them. On the rare occasions I've felt the need for BEGIN/INIT/CHECK/END blocks, they've been an inherent part of the module not the testcode.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.
| [reply] [d/l] |
| [reply] |