| 1 | package PAR::SetupProgname; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 4 | $PAR::SetupProgname::VERSION = '1.002'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use 5.008009; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use Config; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | PAR::SetupProgname - Setup $ENV{PAR_PROGNAME} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | PAR guts, beware. Check L<PAR> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | Routines to setup the C<PAR_PROGNAME> environment variable. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | Read the C<PAR::Environment> manual. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | The C<set_progname()> subroutine sets up the C<PAR_PROGNAME> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | environment variable | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # for PAR internal use only! | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 4 | ▶ | our $Progname = $ENV{PAR_PROGNAME} || $0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$ENV{'PAR_PROGNAME'} || $0
MC/DC0%0/2
$ENV{'PAR_PROGNAME'} || $0
$ENV{'PAR_PROGNAME'}
$0
Truth table33%1/3
A || B
A= $ENV{'PAR_PROGNAME'}B= $0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # same code lives in PAR::Packer's par.pl! | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 7 | ▶ | sub set_progname { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_progname: called CC=15 SCAR=50.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | require File::Spec; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_progname: not called CC=15 SCAR=50.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | if (defined $ENV{PAR_PROGNAME} and $ENV{PAR_PROGNAME} =~ /(.+)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%2/6
defined $ENV{"PAR_PROGNAME"} and $ENV{"PAR_PROGNAME"} =~ /(.+)/
defined $ENV{"PAR_PROGNAME"} and $ENV{"PAR_PROGNAME"} =~ /(.+)/
MC/DC0%0/2
defined $ENV{"PAR_PROGNAME"} and $ENV{"PAR_PROGNAME"} =~ /(.+)/
defined $ENV{"PAR_PROGNAME"}
$ENV{"PAR_PROGNAME"} =~ /(.+)/
MC/DC50%1/2
defined $ENV{"PAR_PROGNAME"} and $ENV{"PAR_PROGNAME"} =~ /(.+)/
defined $ENV{"PAR_PROGNAME"}
$ENV{"PAR_PROGNAME"} =~ /(.+)/
Truth table0%0/3
A and B
A= defined $ENV{"PAR_PROGNAME"}B= $ENV{"PAR_PROGNAME"} =~ /(.+)/
Truth table66%2/3
A and B
A= defined $ENV{"PAR_PROGNAME"}B= $ENV{"PAR_PROGNAME"} =~ /(.+)/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | $Progname = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | $Progname = $0 if not defined $Progname; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | if (( () = File::Spec->splitdir($Progname) ) > 1 or !$ENV{PAR_PROGNAME}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition16%1/6
(() = "File::Spec"->splitdir($PAR::SetupProgname::Progname)) > 1 or not $ENV{"PAR_PROGNAME"}
(() = "File::Spec"->splitdir($PAR::SetupProgname::Progname)) > 1 or not $ENV{"PAR_PROGNAME"}
MC/DC0%0/2
(() = "File::Spec"->splitdir($PAR::SetupProgname::Progname)) > 1 or not $ENV{"PAR_PROGNAME"}
(() = "File::Spec"->splitdir($PAR::SetupProgname::Progname)) > 1
not $ENV{"PAR_PROGNAME"}
MC/DC0%0/2
(() = "File::Spec"->splitdir($PAR::SetupProgname::Progname)) > 1 or not $ENV{"PAR_PROGNAME"}
(() = "File::Spec"->splitdir($PAR::SetupProgname::Progname)) > 1
not $ENV{"PAR_PROGNAME"}
Truth table0%0/3
A or not(B)
A= (() = "File::Spec"->splitdir($PAR::SetupProgname::Progname)) > 1B= not $ENV{"PAR_PROGNAME"}
Truth table33%1/3
A or not(B)
A= (() = "File::Spec"->splitdir($PAR::SetupProgname::Progname)) > 1B= not $ENV{"PAR_PROGNAME"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my $name = $Progname; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | if (-s $name) { $Progname = $name; return } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | if ($Config{_exe}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | $name = "$Progname$Config{_exe}"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | if (-s $name) { $Progname = $name; return } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | foreach my $dir (split /\Q$Config{path_sep}\E/, $ENV{PATH}) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | next if exists $ENV{PAR_TEMP} and $dir eq $ENV{PAR_TEMP}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/6
exists $ENV{"PAR_TEMP"} and $dir eq $ENV{"PAR_TEMP"}
exists $ENV{"PAR_TEMP"} and $dir eq $ENV{"PAR_TEMP"}
MC/DC0%0/2
exists $ENV{"PAR_TEMP"} and $dir eq $ENV{"PAR_TEMP"}
exists $ENV{"PAR_TEMP"}
$dir eq $ENV{"PAR_TEMP"}
MC/DC0%0/2
exists $ENV{"PAR_TEMP"} and $dir eq $ENV{"PAR_TEMP"}
exists $ENV{"PAR_TEMP"}
$dir eq $ENV{"PAR_TEMP"}
Truth table0%0/3
A and B
A= exists $ENV{"PAR_TEMP"}B= $dir eq $ENV{"PAR_TEMP"}
Truth table0%0/3
A and B
A= exists $ENV{"PAR_TEMP"}B= $dir eq $ENV{"PAR_TEMP"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | my $name = File::Spec->catfile($dir, $Progname); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if (-s $name) { $Progname = $name; return } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | if ($Config{_exe}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | $name = File::Spec->catfile($dir, "$Progname$Config{_exe}"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | if (-s $name) { $Progname = $name; return } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||