|Perl: the Markov chain saw|
Re: Minimal Perlby tsee (Curate)
|on Oct 28, 2006 at 15:21 UTC||Need Help??|
The canonical answer to this is: A minimal perl is the full core perl!
But since you explicitly ask for a stripped down perl, I suggest you run Module::ScanDeps (or rather scandeps.pl which comes with the module) on the script you posted.
Make sure to include runtime scanning, so you include the modules suggested by another poster. (Printing %INC entries)
Additionally, you would want to have a look at which shared object files are required by those modules. scandeps.pl can somewhat help with that, too.
Please note that M::ScanDeps deliberately makes the choice of rather including too much than too little because it's the scanning backend for PAR. That is because many PAR users expect a simple-minded "pp -o my.exe my.pl" to produce a working stand-alone application.
That being said, you can try out whether the script would be runnable with those modules using PAR. This should do the trick:
Make sure to put the perl lib into the same directory as the produced binary for testing. Also, the binary might include PAR and its dependencies which wouldn't be required for your script.
Last but not least, I would suggest you don't trust either the %INC dump nor the results of a scandeps.pl run because modules like File::Copy, etc. might use various other modules conditionally or, worse yet, magically. Now, the following lines of code use (at least) two modules that weren't included in the %INC dump seen in this discussion:
Looks innocent enough? Sure does. But it magically uses PerlIO(.pm) and PerlIO::scalar. If perl can't find PerlIO.pm, it throws a warning. If it can't find PerlIO/scalar.pm, it silently opens a file called SCALAR(XXXXXXXXX) instead of the $scalar where XXXXXXXXX is the internal address of the scalar (see "print \$scalar"). Okay, I admit, the latter is a bug in perl which was fixed in the development version.
Perhaps this explains why people claim that the minimal runnable perl is the whole core perl. Working from that to strip the package from not-so-integral packages might work in some cases, though.
Hope this helps! Steffen
Update: Spelling error.