| 1 | package PAR::SetupProgname; | ||||||||||||||||||||||||||||
| 2 | $PAR::SetupProgname::VERSION = '1.002'; | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 8 | ▶ | use 5.006; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 8 | ▶ | 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 | our $Progname = $ENV{PAR_PROGNAME} || $0; | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | # same code lives in PAR::Packer's par.pl! | ||||||||||||||||||||||||||||
| 31 | sub set_progname { | ||||||||||||||||||||||||||||
| 32 | 7 | ▶ | require File::Spec; | ||||||||||||||||||||||||||
|
Subroutine
set_progname: called CC=14 SCAR=42.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 7 | ▶ | if (defined $ENV{PAR_PROGNAME} and $ENV{PAR_PROGNAME} =~ /(.+)/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $ENV{"PAR_PROGNAME"} and $ENV{"PAR_PROGNAME"} =~ /(.+)/
MC/DC50%1/2
defined $ENV{"PAR_PROGNAME"} and $ENV{"PAR_PROGNAME"} =~ /(.+)/
defined $ENV{"PAR_PROGNAME"}
$ENV{"PAR_PROGNAME"} =~ /(.+)/
Truth table66%2/3
A and B
A= defined $ENV{"PAR_PROGNAME"}B= $ENV{"PAR_PROGNAME"} =~ /(.+)/
| |||||||||||||||||||||||||||||
| 35 | 3 | $Progname = $1; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | 7 | ▶ | $Progname = $0 if not defined $Progname; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 7 | ▶ | if (( () = File::Spec->splitdir($Progname) ) > 1 or !$ENV{PAR_PROGNAME}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
(() = "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"}
Truth table33%1/3
A or not(B)
A= (() = "File::Spec"->splitdir($PAR::SetupProgname::Progname)) > 1B= not $ENV{"PAR_PROGNAME"}
| |||||||||||||||||||||||||||||
| 40 | 7 | ▶ | if (open my $fh, $Progname) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 7 | ▶ | return if -s $fh; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | 0 | ▶ | if (-s "$Progname$Config{_exe}") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 0 | $Progname .= $Config{_exe}; | |||||||||||||||||||||||||||
| 45 | 0 | return; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | foreach my $dir (split /\Q$Config{path_sep}\E/, $ENV{PATH}) { | |||||||||||||||||||||||||||
| 50 | 0 | ▶ | next if exists $ENV{PAR_TEMP} and $dir eq $ENV{PAR_TEMP}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
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"}
Truth table0%0/3
A and B
A= exists $ENV{"PAR_TEMP"}B= $dir eq $ENV{"PAR_TEMP"}
| |||||||||||||||||||||||||||||
| 51 | 0 | my $name = File::Spec->catfile($dir, "$Progname$Config{_exe}"); | |||||||||||||||||||||||||||
| 52 | 0 | ▶ | if (-s $name) { $Progname = $name; last } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | 0 | $name = File::Spec->catfile($dir, "$Progname"); | |||||||||||||||||||||||||||
| 54 | 0 | ▶ | if (-s $name) { $Progname = $name; last } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 1; | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | __END__ | ||||||||||||||||||||||||||||