in reply to 'use' inside or outside of package declaration?
I tend to start my modules in exactly the same way as my scripts:
#! perl -slw use strict; package fred; ...
But that's because I often end my modules with:
return 1 if caller; package main; fred->import; ## code that tests the package above goes here.
In this way, running the module as a perl fred.pm runs the test.
This keeps the tests with the tested code, ensures it is kept up to date with that code and acts as documentation for its use. To my mind, this is a 3 way win.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: 'use' inside or outside of package declaration?
by John M. Dlugosz (Monsignor) on May 11, 2011 at 07:52 UTC | |
by BrowserUk (Patriarch) on May 11, 2011 at 08:43 UTC | |
|
Re^2: 'use' inside or outside of package declaration?
by tchrist (Pilgrim) on May 11, 2011 at 19:21 UTC | |
by BrowserUk (Patriarch) on May 11, 2011 at 19:39 UTC | |
by tchrist (Pilgrim) on May 11, 2011 at 22:42 UTC | |
by BrowserUk (Patriarch) on May 12, 2011 at 00:10 UTC | |
|