The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

mods - easy one-stop module shopping

SYNOPSIS

 use mods;   # Various defaults.

 use mods qw(SomePkg Other::Pkg(somefunc, $somevar));
 somefunc($somevar);

 use mods qw(foo bar());    # No imports from bar.pm; default from foo.pm.

More options:

 use mods q{
   diagnostics,     # Integral comments! Commas optional.
   Foo (bar, baz)   # Whitespace ignored.
   Quux   Jolt();   # As you think.
   vars (           # Multilines fine.
         $foo, $bar, $baz
        )
   !strict(refs)    # Unimport.
   $foo, $bar;      # Alternate declaration of vars.
   {$bar=7}         # Compile-time code.
   <this, $that, @theother!> # Export; &this and $that optional.
   [Foo, Bar::Baz]  # Inherit from these.
 };

DESCRIPTION

This pragmatic module is intended as a way to reduce clutter in the prologue of a typical OO module, which often contains a large number of repetitive directives. Encouraging a clean programming style is the intent.

Each import-syntax item in the argument corresponds to a module to be imported. Usage is very similar to normal use statements: no extra arguments runs a default importation; empty parens bypass importation; and arguments within parens, assumed to be literal and separated by commas and/or whitespace, imports those items. An exclamation point before the statement does an unimportation, like the no keyword. Note that both standard modules and compiler pragmas are supported.

Code inside braces is evaluated at compile time, as if it were inside a BEGIN block.

Words inside angle brackets are taken to be things to be exported with the Exporter module (which is loaded for you, and your @ISA appropriately extended). They are placed in @EXPORT_OK, or @EXPORT if you append an exclamation point. If variables (vs. functions), they are declared as globals for you.

Words inside square brackets declare superclasses: they append to @ISA.

Variable names (scalar, array or hash) alone predeclare the variable, as with vars.

"#" introduces comments until end-of-line. If multiple arguments are received, they are first joined together as you would expect.

DEFAULTS

Without you needing to specify it, mods automatically:

  • Uses strict.

  • Uses integer.

  • Declares some common package variables for you (with vars): @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS, @EXPORT_FAIL, $AUTOLOAD, and $VERSION.

If any of these defaults causes a problem in your module which cannot be trivially reversed, precede all other directives by a tilde (~) to suppress them.

BUGS

Implementation of sim_use workhorse function is incomprehensible to the author.

AUTHORS

Jesse Glick, jglick@sig.bsh.com

REVISION

mods/lib/mods.pm last modified Fri, 12 Sep 1997 23:21:20 -0400 release 0.004. Copyright (c) 1997 Strategic Interactive Group. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.