On Apr 24, 8:55 pm, [EMAIL PROTECTED] (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'm doing that in my application for a similar purpose. One thing to watch out for is that it won't give you the .so files for extension modules. (Happily, I don't have to care about that yet.) It also won't find most configuration files or whatever else is loaded during the run. This will also only find things that were actually used during the run. use() is not a problem, since it's unconditional, but require/do/ etc. are runtime. You could always do strace -f -eopen If you don't want to run the script and aren't worried about the caveats above, then you can mimic what -c does. (Which itself can run whatever it wants in BEGIN{} blocks, so it's not guaranteed to be less of a problem than running your code.)