Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Alias (5735)

  (email not shown publicly)

Journal of Alias (5735)

Thursday February 21, 2008
10:34 AM

Vanilla/Strawberry Perl on a Stick

[ #35714 ]

With XML::Parser solved, the next biggest emerging Want To Have for people is clearly showing itself to be relocation.

My primary use case for this feature is colloquially known as "Perl on a Stick", or some form of .zip file release that you can expand onto a flash drive, and then carry a Perl installation in your pocket (with CPAN install support, and potentially a minicpan cache as well)

Since the Win32 binary seems to handle relocation OK, that just leaves various hard-coded paths in config modules, primarily, and Config/

Most suggested solutions for this problem seem to focus on rewriting paths in files from an old path to a new path.

I see this as being fairly naive.

For one, who's to say exactly WHAT you are going from and to. And when will you run this conversion script? In the general case, you need to run it practically every single time you run any installed .bat file, or even every time you invoke the interpreter. Suck.

What people seem to be missing here is that all three of those config files are PERL CODE. This makes them the kind of "config file" that can quite legitimately auto-detect elements of their surrounding environment, like say, the path to perl.exe, and from that derive $Config{bin}, $Config{prefix} and in the Strawberry case, the dist root.

From there, you can easily generate every other path value you need on the fly.

This means there's no need to rewrite anything, the config files just load up with the values you expect, no matter where they run from.

Or at least, I THINK they will.

So I've built relocatable versions of, and Config/ to try and see if it works or not.

I've built the files to drop into any Perl::Dist-based 5.10.0 distribution, although at the moment I only plan to add the feature to the Vanilla Perl builds, and not to the upcoming April Strawberry release.

If experimental usage and testing looks good, it should appear in either the July release (just in time for OSCON) or potentially in a separate mid-quarter "Portable Strawberry" release.

In the mean time, before the next Vanilla build comes out, you can fetch the relocatable config files (extremely experimental) from and try them out with any existing Vanilla/Strawberry 5.10.0 install.

Just drop the files over the top of the ones in your distro, and hopefully it should Just Work.

Any initial problems, feel free to report in comments here. If you have patches and improvements, please mail me to get commit to the repository so you can update the files directly.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • How about this for your next project: AnyPerl on a Stick. ;)

    Binaries for linux, MacOS X, and Windows with all the necessary core XS modules precompiled and a shared pure-Perl site lib. All extractable as a .zip into any place, autodetecting its path as well.

    I see the following dialogue:

    Programmer: "Stick this usb thingy into your computer and run the app."
    Client: "But I'm running on Mac OS..."
    P: "Doesn't matter."
    C: "But I have only Windows at home..."
    P: "Doesn't matter."
    C: "I suspect it doesn't matter, but
    • Sorry for replying to my own post, but thinking about it just one tiny bit further, this is really why I wrote PAR::Repository. (Except not for development of Perl code.)

      Given the platform specific PAR::Repository client and a repository URL, it automatically fetches all that's necessary. The programmer just puts all code in the repository, along with binaries for XS modules of supported platforms.

      Essentially, packaging the following code into a binary with PAR::Packer should do it for a loader:

      use PAR::Rep
  • One small nit from inspecting CPAN::Config [] - the default shell should be read from $ENV{COMSPEC} instead of being hardcoded to "$ENV{SYSTEMROOT}\\system32\\cmd.exe".

    Other than that, I'll give it a spin tomorrow.

    • I think it actually should use $ENV{PERL5SHELL}. c.f. perldoc perlrun -- that's pretty clear on why Perl doesn't use COMSPEC

      -- dagolden
  • Because it's like... frozen? And because I really want to see you outside the convention center in July wearing a white hat in an icecream truck with Perl in huge letters on the side.