[tpm] use from a local directory
J. Bobby Lopez
jbl at jbldata.com
Tue Mar 22 12:15:04 PDT 2011
+1 for FindBin.. use it all the time. That and CWD should help you
accomplish whatever you need to do.
On Tue, Mar 22, 2011 at 2:43 PM, mattp <mattp at cpan.org> wrote:
> 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";' in the
> applications.
> Which is great as long as I don't need to have the application run out of a
> non-current-working-directory.
>
> 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
> installed
> in a standard directory... and the problem then mushrooms.
>
> Then I find out about 'use lib', but it only knows about explicitly defined
> directories. And 'use lib' isn't any different than didling the @INC
> variable
> 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
> now!)
>
> Comments?
> Fulko
>
> _______________________________________________
> toronto-pm mailing list
> toronto-pm at pm.orghttp://mail.pm.org/mailman/listinfo/toronto-pm
>
> Look into the Readonly and FindBin modules combined with use lib.
>
> Cheers,
> Matt
>
> _______________________________________________
> toronto-pm mailing list
> toronto-pm at pm.org
> http://mail.pm.org/mailman/listinfo/toronto-pm
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/toronto-pm/attachments/20110322/dce1787e/attachment.html>
More information about the toronto-pm
mailing list