Roll Your Own Utils
package Your::Utils; use base 'Badger::Utils'; our $EXPORT_ANY = 'random'; sub random { # chosen by fair dice roll return 4; # guaranteed to be random } # See http://xkcd.com/221/
Some time later in a module, far, far away...
use Your::Utils 'random params blessed max min';
Thus Spake Andy:
It's easy to create your own utility modules by subclassing Badger::Utils
.
You should declare any exportable functions using the $EXPORT_ANY
package
variable. This is the Badger equivalent of the @EXPORT_OK
list you define when
using Exporter.pm
. $EXPORT_ANY
can be a reference to a list of names (like
Exporter
), or a single string of whitespace delimited names. i.e. it's
the same shortcut as we used when importing stuff from Badger::Utils
.
You can now import any of your new functions from Your::Utils
module
and all the functions defines by Badger::Utils
, and those of its
delegates (Scalar::Util
, List::Util
, etc).