| 1 | 133 | ▶ | use v5.36; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 2 | package Remote::Perl::Bootstrap; | ||
| 3 | 133 | our $VERSION = '0.005'; | |
| 4 | |||
| 5 | 133 | ▶ | use autodie qw(open close); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 133 | ▶ | use File::Spec; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 133 | ▶ | use Exporter 'import'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 133 | our @EXPORT_OK = qw(bootstrap_payload wait_for_ready READY_MARKER); | |
| 9 | |||
| 10 | # The pre-protocol readiness marker the client sends after being eval'd. | ||
| 11 | 133 | ▶ | use constant READY_MARKER => "REMOTEPERL1\n"; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | |||
| 13 | # Sentinel that terminates the client code in the DATA section. | ||
| 14 | 133 | ▶ | use constant BOOT_END => '__REMOTE_PERL_BOOT_END__'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | |||
| 16 | # The wrapper script sent as the "perl script" over the pipe. | ||
| 17 | # Remote perl compiles and runs this; it reads client code from <DATA> | ||
| 18 | # up to the sentinel, then eval's it. | ||
| 19 | # NOTE: the __END__ token here is intentional and parsed by the remote perl. | ||
| 20 | # NOTE: use strict/warnings explicitly rather than `use v5.36` so that no | ||
| 21 | # feature pragmas leak into eval'd user code via the outer bootstrap scope. | ||
| 22 | # NOTE: WRAPPER runs on the remote side and must stay compatible with Perl 5.10+. | ||
| 23 | 133 | ▶ | use constant WRAPPER => <<'END_WRAPPER'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 24 | use strict; use warnings; | ||
| 25 | binmode(STDIN); binmode(STDOUT); $| = 1; | ||
| 26 | eval(do { | ||
| 27 | my $c = ''; | ||
| 28 | while (defined(my $line = <DATA>)) { | ||
| 29 | last if $line eq "__REMOTE_PERL_BOOT_END__\n"; | ||
| 30 | $c .= $line; | ||
| 31 | } | ||
| 32 | $c | ||
| 33 | }) or do { print STDERR "remperl bootstrap failed: $@\n"; exit 1 }; | ||
| 34 | __END__ | ||