Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Minimal Perl

by tsee (Curate)
on Oct 28, 2006 at 15:21 UTC ( #581088=note: print w/replies, xml ) Need Help??

in reply to Minimal Perl

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 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. 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" 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:

pp -o test.exe -d -M Some::Module ....

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 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:

my $scalar = ''; open FOO, '>', \$scalar; print FOO "Hi there\n"; close FOO;

Looks innocent enough? Sure does. But it magically uses PerlIO(.pm) and PerlIO::scalar. If perl can't find, it throws a warning. If it can't find PerlIO/, 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!

Update: Spelling error.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://581088]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2017-07-25 21:58 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (382 votes). Check out past polls.