Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Dual personality: Module and script

by BrowserUk (Patriarch)
on Aug 03, 2004 at 22:34 UTC ( [id://379850]=note: print w/replies, xml ) Need Help??


in reply to Dual personality: Module and script

I do this all the time. Nearly all my modules have the skeleton:

#! perl -slw package MyPackage; ... return 1 if caller; package main; use Devel::StealthDebug; our $ITERS ||= 10; our $OTHER ||= 'default'; ## run test code here

That allows me to embed the unit test code for the module directly into the module itself, keeping it all together.

The testcode then also serves as sample code for users (should any of my half-baked ideas ever get refined enough that I feel able to let it loose on the world :).


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://379850]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2024-04-25 20:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found