On Apr 30, 2007, at 2:24 PM, [EMAIL PROTECTED] wrote:
On Tue, 24 Apr 2007, Sherm Pendley wrote:
On Apr 24, 2007, at 11:39 PM, [EMAIL PROTECTED] wrote:
Is there a way to pre-compile a script to figure out what modules
it may need so I can download them and store them in a cached lib
directory?
Add code that prints %INC upon exiting, then run the script -
that'll give you a list of every file that was use()d or require()
d during the script's run.
I need to dynamically download both the script AND any modules the
script may require. This means I need to dynamically download the
script itself, then just before running the script, figure out what
modules are required and download them as well.
To say it another way, I don't know the name of the script (or any
modules it may need) before it's requested.
The client app I intend to write will be written in C and include
an embedded perl interpreter. The user will run the client (again
written in C)... and issue a command. This command will run on the
server, but it MAY include a client-side component written in
perl. The C app will send a message to the server to see if
there's a client-side perl component and if so, download the perl
script.
It's at this point I'd like to be able to somehow detect (without
actually running the script) what modules it may need, so I can
download them.
If you want to detect that before the script is fetched, the only way
to do that would be to fetch an accompanying file that lists them.
Another possible alternative would be to somehow interject some
code into the perl interpreter just before it attempts to look for
an external file (ie searches %INC).... assuming that's even possible.
That's not only possible, it's pretty easy - just push a code ref
onto the end of @INC. The sub that's pointed to by the code ref will
be called when a requested module isn't found at any of the previous
directories pointed to by @INC; at that point you can download it.
sherm--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net