| 1 | |||||||||||
| 2 | package Perl::Command; | ||||||||||
| 3 | |||||||||||
| 4 | 2 | ▶ | use strict 'vars', 'subs'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 2 | ▶ | use 5.006; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 2 | our $VERSION = 0.01; | |||||||||
| 9 | |||||||||||
| 10 | =head1 NAME | ||||||||||
| 11 | |||||||||||
| 12 | Perl::Command - return an ARGV for running this perl | ||||||||||
| 13 | |||||||||||
| 14 | =head1 SYNOPSIS | ||||||||||
| 15 | |||||||||||
| 16 | use Perl::Command; | ||||||||||
| 17 | |||||||||||
| 18 | # clear PERL5LIB and PERL5OPT to stop any monkey business | ||||||||||
| 19 | NOLIB; | ||||||||||
| 20 | |||||||||||
| 21 | system(@PERL, "-le", "print for @INC"); | ||||||||||
| 22 | |||||||||||
| 23 | =head1 DESCRIPTION | ||||||||||
| 24 | |||||||||||
| 25 | This module exports one symbol - @PERL, which is very similar to C<$^X> | ||||||||||
| 26 | (see L<perlvar/$^X>), except it also contains a list of commands which | ||||||||||
| 27 | will give the sub-perl all of the same @INC paths as this one. | ||||||||||
| 28 | |||||||||||
| 29 | This is a very trivial module; its principle use is for bundling with | ||||||||||
| 30 | modules whose test scripts need to test running scripts. | ||||||||||
| 31 | |||||||||||
| 32 | =cut | ||||||||||
| 33 | |||||||||||
| 34 | 2 | our @PERL; | |||||||||
| 35 | 2 | ▶ | use base 'Exporter'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 36 | |||||||||||
| 37 | 2 | our @EXPORT = qw(@PERL NOLIB); | |||||||||
| 38 | |||||||||||
| 39 | 2 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=5 SCAR=16.1
| |||||||||||
| 40 | 2 | local ( $ENV{PERL5LIB} ) = ""; | |||||||||
| 41 | 2 | local ( $ENV{PERL5OPT} ) = ""; | |||||||||
| 42 | 2 | my @default_inc = `$^X -le 'print for \@INC'`; | |||||||||
| 43 | 2 | chomp($_) for @default_inc; | |||||||||
| 44 | |||||||||||
| 45 | 2 | my @add_inc; | |||||||||
| 46 | 2 | for my $path (@INC) { | |||||||||
| 47 | 18 | ▶ | next if ref $path; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | 18 | ▶ | if ( !grep { $_ eq $path } @default_inc ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | 8 | push @add_inc, $path; | |||||||||
| 50 | } | ||||||||||
| 51 | } | ||||||||||
| 52 | 2 | @PERL = ( $^X, map { "-Mlib=$_" } @add_inc ); | |||||||||
| 53 | } ## end BEGIN | ||||||||||
| 54 | |||||||||||
| 55 | 0 | ▶ | sub NOLIB { | ||||||||
|
Subroutine
NOLIB: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 56 | 0 | delete $ENV{PERL5LIB}; | |||||||||
| 57 | 0 | delete $ENV{PERL5OPT}; | |||||||||
| 58 | } | ||||||||||
| 59 | |||||||||||
| 60 | 2 | 1; | |||||||||
| 61 | |||||||||||
| 62 | __END__ | ||||||||||