Sheol has asked for the wisdom of the Perl Monks concerning the following question:
Well, I've read up a little on Python (easy, easy... I didn't come here to start a langauge war), and one thing I've noticed a lot in their teachings, is in files that are meant for including in other files have a little something at the bottom of the code that goes something like:
(elaboration '(the young monk is easily excited) '(I would like to be able to do this with perl as well as Python. The solution...)) I would guess it would be one of:if __package__ eq __main__: # do stuff to test to see if package is working.
However, I am sure all of those are flawed. I am also sure t here is a better way to "emulate" what Python programmers do in perl. For those of you unfamilure with this proramming practice, it is done so each portion of a project can be tested indepedandtly. However the same code that tests it, does not get ran when it is included. Now, as far as I am concerned running:if($main == "hardcoded::package::name") { } if($main == $PROGRAM_NAME) { } if($main->isa("hardcoded::package::name")) { }
As that is just messy. This would make debugging my stuff a lot easier. Thank you kindly$debug && print "some code"; $debug && print "some more code"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Self Testing Modules
by demerphq (Chancellor) on Dec 18, 2005 at 00:21 UTC | |
by Happy-the-monk (Canon) on Dec 18, 2005 at 01:00 UTC | |
by demerphq (Chancellor) on Dec 18, 2005 at 09:59 UTC | |
by Sheol (Novice) on Dec 18, 2005 at 00:27 UTC | |
by demerphq (Chancellor) on Dec 18, 2005 at 10:02 UTC | |
|
Re: Self Testing Modules
by eyepopslikeamosquito (Archbishop) on Dec 18, 2005 at 21:32 UTC | |
|
Re: Self Testing Modules
by eyepopslikeamosquito (Archbishop) on Dec 18, 2005 at 21:21 UTC | |
by BrowserUk (Patriarch) on Dec 18, 2005 at 21:28 UTC | |
by eyepopslikeamosquito (Archbishop) on Dec 18, 2005 at 21:42 UTC | |
by BrowserUk (Patriarch) on Dec 18, 2005 at 22:01 UTC | |
by demerphq (Chancellor) on Dec 18, 2005 at 23:34 UTC | |
| |
by eyepopslikeamosquito (Archbishop) on Dec 19, 2005 at 01:15 UTC | |
|