blib/lib/Perl/Command.pm

filter: Statementstmt 93.1% 27 / 29 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 87.5% 35 / 40 CC 5 SCAR 11.3
CC
5
Cov
91%
BEGIN
5.0
NOLIB
2.0
BEGIN
1.0
CRAP 3.1
↑ Summary
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
BranchTrueFalseTotal
if ref $path 0 18 18
48 18 ▶ if ( !grep { $_ eq $path } @default_inc ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {$_ eq $path;} @default_inc) 8 10 18
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__
↑ Summary