Re: *more* relocatable perl

Graham Knop <[email protected]> Wed, 22 Jul 2026 00:42:04 +0200
Newsgroups gmane.comp.lang.perl.perl5.porters
Message-ID <CAM=m89HLBSLrFFq=YDuawW-vB2AyMawvQPNQJj0q_SpdmNcuKA@mail.gmail.com>
On Sat, Jul 18, 2026 at 11:21=E2=80=AFPM Gianni Ceccarelli via perl5-porter=
s
<[email protected]> wrote:
>
> Again, I have made it work, I'm asking =C2=ABdoes it make sense to do for
> binary paths what we're already doing for library paths, in the core
> perl distribution?=C2=BB
>
> On 2026-07-18 Leon Timmermans <[email protected]> wrote:
> > I suspect you can make this work by using the usesitecustomize
> > feature to monkeypatch various %Config values. %Config can be
> > monkeypatched by (ab)using its tied value.
>
> I didn't want to go that route because it would have loaded Config.pm
> in every process (not a big deal but annoying)
>
> Instead I patched Config.pm itself, after building perl but before
> tar-ing it up:
>
> I replace `sub FETCH {` with:
>
> ```
> sub FETCH {
>     my ($self, $key) =3D @_;
>     my $v =3D $self->_orig_fetch($key);
>     return undef unless defined $v;
>     my $replacement =3D ($^X =3D~ s{/bin/perl$}{}r);
>     $v =3D~ s{/path/to/where/I/built/perl\b}{$replacement}g;
>     return $v;
> }
> sub _orig_fetch {
> ```
>
> --
>         dakkar - <Mobilis in mobile>
>         GPG public key fingerprint =3D A071 E618 DD2C 5901 9574
>                                      6FE2 40EA 9883 7519 3F88
>                             key id =3D 0x75193F88
>

This is very similar to what the Portable and Portable::Dist modules
do. They are used by the strawberry perl portable variants.
Portable::Dist modifies the Config.pm file to load the Portable
module, which sets up %Config::Config appropriately based on the
executable path. I've only seen these used for strawberry perl, so I
don't know how widely reusable they are.

https://metacpan.org/pod/Portable
https://metacpan.org/pod/Portable::Dist