+1 for FindBin.. use it all the time. That and CWD should help you accomplish whatever you need to do.<br><br><div class="gmail_quote">On Tue, Mar 22, 2011 at 2:43 PM, mattp <span dir="ltr"><<a href="mailto:mattp@cpan.org">mattp@cpan.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div bgcolor="#ffffff" text="#000000"><div><div class="h5">
On 03/22/2011 02:22 PM, Fulko Hew wrote:
</div></div><blockquote type="cite"><div><div class="h5"><font face="courier new,monospace">I don't know if I'm
doing this right, or in the best manner...<br>
<br>
a) I have a compiler that generates Perl classes/source files
based on data you feed it.<br>
b) People then write applications that 'include' those source
files.<br>
<br>
Right now I have been using (for example) 'require "<a href="http://module1.pm" target="_blank">module1.pm</a>";'
in the applications.<br>
Which is great as long as I don't need to have the application
run out of a<br>
non-current-working-directory.<br>
<br>
But now I have a situation where the generated modules have 'use
constant' in them<br>
and I need to have the callers be able to use those constants
easily.<br>
<br>
At the moment they need to do $x = Module1::CONSTANT_1(); in
order for it to work.<br>
Something more natural would be </font><font face="courier
new,monospace">$x = Module1::CONSTANT_1; ie. without the parens.<br>
</font><br>
<font face="courier new,monospace">To do that I need to use
export/import (right?)<br>
And the only way to do that is something like 'use module qw/</font><font face="courier new,monospace">CONSTANT_1/;<br>
<br>
But then I'm using USE, not REQUIRE, and then the modules need
to be installed<br>
in a standard directory... and the problem then mushrooms.<br>
<br>
Then I find out about 'use lib', but it only knows about
explicitly defined<br>
directories. And 'use lib' isn't any different than didling the
@INC variable<br>
anyway. And there doesn't seem to be an easy way of didling
either to get it<br>
to include the 'invoked' directory (only the
current-working-dirctory).<br>
<br>
I figure its easier to ship the executable and its modules in a
single<br>
directory, than to ship the executable (where the user can put
it anywhere<br>
they want) and then force the user to 'install' the remaining
modules.<br>
<br>
<br>
Whats a guy to do?<br>
(Ah, statically compiled executables sure are looking easy right
about now!)<br>
<br>
Comments?<br>
Fulko<br>
<br>
</font>
</div></div><pre>_______________________________________________
toronto-pm mailing list
<div class="im"><a href="mailto:toronto-pm@pm.org" target="_blank">toronto-pm@pm.org</a>
<a href="http://mail.pm.org/mailman/listinfo/toronto-pm" target="_blank">http://mail.pm.org/mailman/listinfo/toronto-pm</a>
</div></pre> </blockquote>
Look into the Readonly and FindBin modules combined with use lib.<br>
<br>
Cheers,<br>
Matt
</div>
<br>_______________________________________________<br>
toronto-pm mailing list<br>
<a href="mailto:toronto-pm@pm.org">toronto-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/toronto-pm" target="_blank">http://mail.pm.org/mailman/listinfo/toronto-pm</a><br>
<br></blockquote></div><br>