[tpm] use from a local directory
mattp at cpan.org
Tue Mar 22 11:43:02 PDT 2011
On 03/22/2011 02:22 PM, Fulko Hew wrote:
> I don't know if I'm doing this right, or in the best manner...
> a) I have a compiler that generates Perl classes/source files based on
> data you feed it.
> b) People then write applications that 'include' those source files.
> Right now I have been using (for example) 'require "module1.pm
> <http://module1.pm>";' in the applications.
> Which is great as long as I don't need to have the application run out
> of a
> But now I have a situation where the generated modules have 'use
> constant' in them
> and I need to have the callers be able to use those constants easily.
> At the moment they need to do $x = Module1::CONSTANT_1(); in order for
> it to work.
> Something more natural would be $x = Module1::CONSTANT_1; ie. without
> the parens.
> To do that I need to use export/import (right?)
> And the only way to do that is something like 'use module qw/CONSTANT_1/;
> But then I'm using USE, not REQUIRE, and then the modules need to be
> in a standard directory... and the problem then mushrooms.
> Then I find out about 'use lib', but it only knows about explicitly
> directories. And 'use lib' isn't any different than didling the @INC
> anyway. And there doesn't seem to be an easy way of didling either to
> get it
> to include the 'invoked' directory (only the current-working-dirctory).
> I figure its easier to ship the executable and its modules in a single
> directory, than to ship the executable (where the user can put it anywhere
> they want) and then force the user to 'install' the remaining modules.
> Whats a guy to do?
> (Ah, statically compiled executables sure are looking easy right about
> toronto-pm mailing list
> toronto-pm at pm.org
Look into the Readonly and FindBin modules combined with use lib.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the toronto-pm