blob: 23c7e1e3b5fdae50845af866e4d1872f943a5236 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
package PAR::SetupProgname;
$PAR::VERSION = '0.982';
use 5.006;
use strict;
use warnings;
use Config ();
=head1 NAME
PAR::SetupProgname - Setup $ENV{PAR_PROGNAME}
=head1 SYNOPSIS
PAR guts, beware. Check L<PAR>
=head1 DESCRIPTION
Routines to setup the C<PAR_PROGNAME> environment variable.
Read the C<PAR::Environment> manual.
The C<set_progname()> subroutine sets up the C<PAR_PROGNAME>
environment variable
=cut
# for PAR internal use only!
our $Progname = $ENV{PAR_PROGNAME} || $0;
# same code lives in PAR::Packer's par.pl!
sub set_progname {
require File::Spec;
if (defined $ENV{PAR_PROGNAME} and $ENV{PAR_PROGNAME} =~ /(.+)/) {
$Progname = $1;
}
$Progname = $0 if not defined $Progname;
if (( () = File::Spec->splitdir($Progname) ) > 1 or !$ENV{PAR_PROGNAME}) {
if (open my $fh, $Progname) {
return if -s $fh;
}
if (-s "$Progname$Config::Config{_exe}") {
$Progname .= $Config::Config{_exe};
return;
}
}
foreach my $dir (split /\Q$Config::Config{path_sep}\E/, $ENV{PATH}) {
next if exists $ENV{PAR_TEMP} and $dir eq $ENV{PAR_TEMP};
my $name = File::Spec->catfile($dir, "$Progname$Config::Config{_exe}");
if (-s $name) { $Progname = $name; last }
$name = File::Spec->catfile($dir, "$Progname");
if (-s $name) { $Progname = $name; last }
}
}
1;
__END__
=head1 SEE ALSO
The PAR homepage at L<http://par.perl.org>.
L<PAR>, L<PAR::Environment>
=head1 AUTHORS
Audrey Tang E<lt>cpan@audreyt.orgE<gt>,
Steffen Mueller E<lt>smueller@cpan.orgE<gt>
L<http://par.perl.org/> is the official PAR website. You can write
to the mailing list at E<lt>par@perl.orgE<gt>, or send an empty mail to
E<lt>par-subscribe@perl.orgE<gt> to participate in the discussion.
Please submit bug reports to E<lt>bug-par@rt.cpan.orgE<gt>. If you need
support, however, joining the E<lt>par@perl.orgE<gt> mailing list is
preferred.
=head1 COPYRIGHT
Copyright 2002-2008 by Audrey Tang E<lt>cpan@audreyt.orgE<gt>.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
See L<http://www.perl.com/perl/misc/Artistic.html>
=cut
|