sourcecode
Intrepid
<code>
#! /usr/bin/env perl
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
if 0; # not running under some shell
=for gpg
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
=head1 NAME
showPerlDirConfig - explore (pretty-print) the basis of directory locations
of the Perl installation configuration matching the perl interpreter currently
being run.
=head2 VERSION
This POD documents
---------------------------------------------------------------------
* version 2004.01.09 *
---------------------------------------------------------------------
=head1 SYNOPSIS
$ showPerlDirConfig
$ /opt/bin/myfunkyperl showPerlDirConfig
=cut
# ---------------------------------------------------------------------
# internal CVS - RCS version control information:
## somian ## 1.7 ##
## 2004/01/10 01:54:28 ##
# ---------------------------------------------------------------------
use strict;
use Config;
use File::Spec;
$^W = 1;
$\ = "\n";
my $Ll = 0;
my $Stogg = 0;
my $headr =
sub {
my($perlFQpath,$stringL) = @{&pselfIdentity};
my $margin = calc_midbuffs ($stringL => $Ll);
my($decoL,$decoR) = ('','');
if ($margin >= 6)
{
$decoL = '||:' ; $decoR = ':||';
}
my $visi = "$decoL $perlFQpath $decoR";
my $spadd = $margin - 3 - length $decoL;
$spadd += length $visi;
my $formtl = "%${spadd}s";
print "Installation directory target configuration for "
,"the Perl binary installed as";
printf $formtl => $visi;
print "\n\n" , ( '-' x $Ll);
};
## *** <main execution> *** ##
print join "\n"
=>(
map {
my $keyarr=$_; # we get scoping confusion induced err if not.
$Stogg++ || &$headr;
my $ins=$Config::Config{$keyarr->[0]};
my $ndi=substr($keyarr->[0],0,7) eq 'install'? "\n".('-'x$Ll):'';
sprintf( "%-20s". " "x8 ."%s$ndi", $keyarr->[0], $ins )
}
sort { $a->[1] cmp $b->[1] }
map [ $_, kenzoku($_) ],
grep { /^(?!installusr|ta|mv|mu|d_)\w*
(?:bin(?!compat)|arch(?!name|obj)|man(?:1|3)(?!ext)|priv|
(?:vendor|site)(?!lib_|prefix))
[a-z]*
/x } keys %Config::Config
);
exit;
## *** </main execution> *** ##
sub kenzoku {
my $mwa=shift;
my $ins=$Config::Config{$mwa};
$Ll = ($Ll <= length($ins)+28)? length($ins)+28 : $Ll;
my $rwa=$mwa;
$rwa =~s/^install// or $rwa =~s/exp$//;
return
$rwa .( substr($mwa,0,7) eq 'install'? 3 :
substr($mwa,-3) eq 'exp'? 2 : 1 );
}
sub pselfIdentity {
my $pintexe=$^X;
unless( $Config::Config{exe_ext}
and
substr($pintexe,-4) eq $Config::Config{exe_ext} )
{
$pintexe .= $Config::Config{exe_ext};
}
unless( File::Spec->file_name_is_absolute($pintexe) ) {
$pintexe = (grep -x, map File::Spec->catfile($_,$pintexe)
, split /\Q$Config::Config{path_sep}/, $ENV{PATH})[0];
}
return( [$pintexe , length $pintexe] );
}
sub calc_midbuffs
{
my( $textW, $availW ) = @_ ;
if ( $ENV{'COLUMNS'} and ($ENV{'COLUMNS'} > $availW)
and ($textW > int(.9 * $availW)) )
{
$availW = $ENV{'COLUMNS'};
}
my $leew = $availW - $textW;
return int( ($leew + 0.5) / 2 );
}
__END__
=head1 DESCRIPTION
This is a simple program written for the curious Perl newbie or the thorough
perl administrator (the system admin responsible for the installation and
operating efficiency, and improvement thereof, and upgrades to, Perl...) who
wants to know more about the internal layout of the important directories
where Perl parts are kept.
Specifically, the program will display the directories where core and
site-extension perl modules are installed, allowing the prediction of where
yet-to-be built modules are going to land when Perl's module installation
facilities are done with them.
=head2 NOTES
If the F<Config.pm> file read by your Perl interpreter during operation is
hosed (incorrect, tampered with, or invalid due to a binary being compiled on
a different system), then the resulting data displayed by this program
cannot be trusted. Garbage in, garbage out.
=head1 SEE ALSO
L<ExtUtils::MakeMaker>, L<Config>, L<perl>
=head1 AUTHOR & CREDITS
Soren Andersen E<lt>C<somian -AT- pobox *DOT* com>E<gt> a.k.a
E<lt>C<somian -AT- cpan *DOT* org>E<gt> is responsible for all badness.
However Perl Monks "castaway" and "Aristotle" helped to point him towards
solutions that led to an improved script.
This release is cryptographically signed. The author / maintainers' GnuPG/OpenPGP
key is identified by No. C<0x4E244EA6> and should be locateable for verification
on keyservers worldwide. "perlsign" (modified code) was used as the signing tool.
=head1 COPYRIGHT AND LICENSE
Copyright 2003,2004 by Soren Andersen, U.S.A.
This program is Free software; you may redistribute it and/or modify it under the
same terms as Perl itself (See the F<LICENSE> file in your Perl source kit). Part
of that license stipulates that you, the user, agrees that this Free software is
accepted "AS-IS" and comes with absolutely NO WARRANTY, not even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
=head4 Any POD appearing below this line are merely entries for support of
L<the CPAN Scripts Repository|http://www.cpan.org/scripts/index.html> and its automata.
=begin text
-----------------------------------------------------------------
=end text
=begin html
<hr>
=end html
=pod OSNAMES
any
=pod SCRIPT CATEGORIES
UNIX : System_administration
CPAN
=cut
=begin gpg
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE//1uOBXOj2U4kTqYRAn+7AJ4lIvhZR393IkxuptUBLjKaON6SSACfQ9tv
fOFres1Pkt0k1VjW7vh9ftc=
=4e80
-----END PGP SIGNATURE-----
=end gpg
</code>
<p>
This simple text-term program shows the breakdown of the Perl configuration
belonging to that Perl interpreter being run (ordinarily "<tt>perl</tt>"). The
utility of such a thing will not necessarily be obvious unless the user is an admin who is maintaining one or more Perl
installations (more than one is possible per system), or a module author who is trying
to write build infrastructure. In the author's experience, it
is sometimes desireable to see at a glance the organization of the principle Perl
installation directories. Being able to do so may be particularly advantageous when
trying to install or upgrade modules and the installation is not going smoothly.
<readmore>
<p>
This script was developed on a system running a *nix-type OS (Linux, Debian 3.0r1)
and tested against Perl versions 5.6.1 and 5.8.0.
<p>
<i>Update:</i> <tt>Thu Aug 7 2003 15:05 UTC</tt><br />
Removed the code relying on
<tt>File::Find</tt> and replaced it with a corrected, simpler subroutine. Perl Monk
[Aristotle] helped direct my attention to that solution [id://281639|in the follow-up below].
<p>
<i>Update:</i> <tt>Sun Aug 17 2003 14:03 UTC</tt><br />
Added the <tt>*man*</tt> dirs to the report. On most or all *nix-like platforms, we
install manpages at module installation time, including in <em>cygwin</em>.
<p>
Also added a test to make sure a
Win32 perl was looked for with <tt>.exe</tt> suffix. No previous reports from Win32
users had indicated a problem, but some edge case might require this care.
<p>
<i>Update:</i> <tt>Sat Jan 10 2004 07:10 UTC</tt><br />
Considerable changes made but they only affect the formatting of the header slightly.</p>
<p>
See <a href="http://intrepid.perlmonk.org/software/scriptscode/showPerlDirConfig">download from
Intrepid's perlmonk site</a> for the most up-to-date release of this script.
<p>
<i>Update:</i> <tt>Tue, 13 Feb 2007</tt><br />
The [http://intrepid.perlmonk.org/|Intrepid perlmonk.org site] has been partially rebuilt. See the following links offered for readers' convenience:
<hr><ul> <!--
<li>This script's POD:
[http://intrepid.perlmonk.org/scriptspod/showPerlDirConfig.pod|pod]</li>
<li>This script as syntax-hilighted HTML code alone, with no POD:
[http://intrepid.perlmonk.org/scriptsynh/showPerlDirConfig.html|code-hilighted]</li>
-->
<li>This script's "<b>production copy</b>" with cryptographic signature and all POD in-line:
[http://intrepid.perlmonk.org/software/scriptscode/showPerlDirConfig|signed]</li>
</ul><hr></p>
Perl Administration
Soren Andersen <somian -AT- pobox *DOT* com> or <somian -AT- cpan *DOT* org>