Eric Wilhelm > Package-Tent > Package::Tent

Download:
Package-Tent-v0.0.1.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

Package::Tent - temporary package infrastructure

SYNOPSIS ^

This module allows you to setup camp inside an existing module/program with minimal commitment to filenames, while still being able to use the same require/use statements of normal code.

  use Package::Tent sub {
    package Who::sYourDaddy;
    sub thing {
      print "hello world\n";
    }
    1;
  };
  use Package::Tent sub {
    package What::sInAName;
    use base 'Who::sYourDaddy';
    sub method {
      $_[0]->thing;
    }
    __PACKAGE__;
  };

  use What::sInAName;
  What::sInAName->method;

USAGE ^

The 'use Package::Tent sub {...}' statement is equivalent to wrapping your package in a BEGIN block and setting an entry in %INC.

Note that the first example simply returns a true value, while the second explicitly returns the package name using the __PACKAGE__ token. You may use either method.

The implicit form will cause Package::Tent to attempt opening and scanning the file containing the calling code. The latter is more robust in strange (PAR, @INC hooks, etc.) environments, but is less convenient.

NOTES ^

It is not wise to install a datacenter in a tent. Need I say more?

This module was designed to reduce development time by allowing me to maintain my train of thought. The scenario is that you're coding along in some module or program and you realize the need for a support module (or even a few of them.) Package::Tent allows you to keep writing code while you're thinking rather than stopping long enough to commit to a name, create a file, maybe add it to version control, etc.

It should be similarly useful in single-file prototypes or other experimental code. Hopefully, lowering the file-juggling overhead encourages you to start your code with a modular style. When the prototype becomes the finished product (as it so often does), the refactoring is nearly mechanical as opposed to a difficult untangling of ad-hoc variables.

Methods ^

import

  use Package::Tent sub {
    ...
  };

  Package::Tent->import($subref);

_find_package

  Package::Tent->_find_package($file, $line);

AUTHOR ^

Eric Wilhelm @ <ewilhelm at cpan dot org>

http://scratchcomputing.com/

BUGS ^

If you found this module on CPAN, please report any bugs or feature requests through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

If you pulled this development version from my /svn/, please contact me directly.

COPYRIGHT ^

Copyright (C) 2007 Eric L. Wilhelm, All Rights Reserved.

NO WARRANTY ^

Absolutely, positively NO WARRANTY, neither express or implied, is offered with this software. You use this software at your own risk. In case of loss, no person or entity owes you anything whatsoever. You have been warned.

LICENSE ^

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: