/usr/share/perl5/Padre/Perl.pm is in padre 1.00+dfsg-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | package Padre::Perl;
# TO DO: Merge this into Probe::Perl some day in the future when this is
# perfected, stable and beyond reproach.
=pod
=head1 NAME
Padre::Perl - A more nuanced "Where is Perl" module than Probe::Perl
=head1 DESCRIPTION
Even though it has only had a single release, L<Probe::Perl> is the "best
practice" method for finding the current Perl interpreter, so that we can
make a system call to a new instance of the same Perl environment.
However, during the development of L<Padre> we have found the feature set
of L<Probe::Perl> to be insufficient.
C<Padre::Perl> is an experimental attempt to improve on L<Probe::Perl>
and support a wider range of situations. The implementation is being
contained to the L<Padre> project until we have competently "solved" all
of the problems that we care about.
=head2 GUI vs Command Line
On some operating systems, different Perl binaries need to be called based
on whether the process will be executing in a graphical environment versus
a command line environment.
On Microsoft Windows F<perl.exe> is the command line Perl binary and
F<wperl.exe> is the windowing Perl binary.
On Mac OS X (Darwin) F<perl.exe> is the command line Perl binary and
F<wxPerl.exe> is a wxWidgets-specific Perl binary.
=head2 PAR Support
PAR executables do not typically support re-invocation, and implementations
that do are only a recent invention, and do not support the normal Perl
flags.
Once implemented, we may try to implement support for them here as well.
=head1 FUNCTIONS
=cut
use 5.008005;
use strict;
use warnings;
# Because this is sometimes used outside the Padre codebase,
# don't put any dependencies on other Padre modules in here.
our $VERSION = '1.00';
my $perl = undef;
=pod
=head2 C<perl>
The C<perl> function is equivalent to (and passes through to) the
C<find_perl_interpreter> method of L<Probe::Perl>.
It should be used when you simply need the "current" Perl executable and
don't have any special needs. The other functions should only be used once
you understand your needs in more detail.
Returns the location of current F<perl> executable, or C<undef> if it
cannot be found.
=cut
sub perl {
# Find the exact Perl used to launch Padre
return $perl if defined $perl;
# Use the most correct method first
require Probe::Perl;
my $_perl = Probe::Perl->find_perl_interpreter;
if ( defined $_perl ) {
$perl = $_perl;
return $perl;
}
# Fallback to a simpler way
require File::Which;
$_perl = scalar File::Which::which('perl');
$perl = $_perl;
return $perl;
}
=pod
=head2 C<cperl>
The C<cperl> function is a Perl executable location function that
specifically tries to find a command line Perl. In some situations you
may critically need a command line Perl so that proper C<STDIN>, C<STDOUT>
and C<STDERR> handles are available.
Returns a path to a command line Perl, or C<undef> if one cannot be found.
=cut
sub cperl {
my $path = perl();
# Cascade failure
unless ( defined $path ) {
return;
}
if ( $^O eq 'MSWin32' ) {
if ( $path =~ s/\b(wperl\.exe)\z// ) {
# Convert to non-GUI
if ( -f "${path}perl.exe" ) {
return "${path}perl.exe";
} else {
return "${path}wperl.exe";
}
}
# Unknown, give up
return $path;
}
if ( $^O eq 'darwin' ) {
if ( $path =~ s/\b(wxPerl)\z// ) {
# Convert to non-GUI
if ( -f "${path}perl" ) {
return "${path}perl";
} else {
return "${path}wxPerl";
}
}
# Unknown, give up
return $path;
}
# No distinction on this platform, or we have no idea
return $path;
}
=pod
=head2 C<wxperl>
The C<wxperl> function is a Perl executable location function that
specifically tries to find a windowing Perl for running wxWidgets
applications. In some situations you may critically need a wxWidgets
Perl so that a command line box is not show (Windows) or so that Wx
starts up properly at all (Mac OS X).
Returns a path to a Perl suitable for the execution of L<Wx>-based
applications, or C<undef> if one cannot be found.
=cut
sub wxperl {
my $path = perl();
# Cascade failure
unless ( defined $path ) {
return;
}
if ( $^O eq 'MSWin32' ) {
if ( $path =~ s/\b(perl\.exe)\z// ) {
# Convert to GUI version if we can
if ( -f "${path}wperl.exe" ) {
return "${path}wperl.exe";
} else {
return "${path}perl.exe";
}
}
# Unknown, give up
return $path;
}
if ( $^O eq 'darwin' ) {
if ( $path =~ s/\b(perl)\z// ) {
# Convert to Wx launcher
if ( -f "${path}wxPerl" ) {
return "${path}wxPerl";
} else {
return "${path}perl";
}
}
# Unknown, give up
return $path;
}
# No distinction on this platform, or we have no idea
return $path;
}
1;
=pod
=head1 COPYRIGHT & LICENSE
Copyright 2008-2013 The Padre development team as listed in Padre.pm.
This program is free software; you can redistribute
it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the
LICENSE file included with this module.
=cut
# Copyright 2008-2013 The Padre development team as listed in Padre.pm.
# LICENSE
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl 5 itself.
|