[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

TMTOWTDI (I hope acceptably, this once)



Hours after I started, I am using this message to test the whole Gmane-nntp 
gateway to Debian-list mechanism and see if I can post. Because I care 
about Debian and care about perl, this is the first List I am trying. I've 
just subscribed to debian-perl in the ordinary fashion and am hoping to now 
trigger Gmane to email me an authorization message.

Just to make this a little less unpopular a thing to do, I am attaching a 
small Perl script I wrote which may be useful for a few readers (actually 
its a broadly if only occasionally useful thing, but I am trying to sound 
modest ;-).

 Yours Truly,
  Soren Andersen

This script displays the Perl installation directory hierarchy list for the 
currently "active" (primacy in PATH or deliberately qualified on 
invocation) perl executable. It's called "showPerlDirConfig". It is 
licensed under the same terms as Perl itself. It's meant to be run from a 
terminal / console, not as a cgi tool, btw. It's for people admin-ing a 
perl installation or is "just" a learning tool for novices.

,----[ showPerlDirConfig ]
| #! /usr/bin/env perl
| 
| =for gpg
| -----BEGIN PGP SIGNED MESSAGE-----
| Hash: SHA1
| 
| =cut
| 
| # UNIX users without the 'env' prog must change the top line, to reflect
| # the location of the perl executable matching the Config wanted, or else
| # run the script by invoking the interpreter directly on the commandline.
| # Win32 users should not have to worry about the #! line at all.
| 
| # ---------------------------------------------------------------------
| # "showPerlDirConfig" - explore the basis of directory locations
| #    comprising the Perl installation being currently used.
| # (C)2003 Soren Andersen <somian -AT- cpan *DOT* org>
| # This program is Free Software, it may be modified or redistributed
| # under the same terms as Perl itself.
| #    *version* 2003.08.17
| # ---------------------------------------------------------------------
| 
| use strict;
| $^W++;
| use Config;
| use File::Spec;
| 
| $\="\n";
| $|++;
| my $Ll=0;
| my $Stogg=0;
| my $Nme = sub {
|    printf "\nWe are checking configuration of the Perl installed in"
|          ." %s :\n%s\n", SelfIdentity(), '-'x$Ll;
|               };
| 
| print join "\n"
|    ,(
|  map {
|      my $keyarr=$_; # we get scoping confusion induced err if not.
|      $Stogg++ || &$Nme;
|      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 [ $_, GrpOrder($_) ],
|   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
|     );
| 
| sub GrpOrder  {
|     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 SelfIdentity  {
|     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];
|     }
|     $pintexe;
| }
| 
| __END__
| 
| =pod
| 
| =head1 NAME
| 
| showPerlDirConfig
| 
| =head1 VERSION
| 
| This is version 2003.08.17
| 
| =head1 SYNOPSIS
| 
|  $ showPerlDirConfig
|  $ myfunkyperl showPerlDirConfig
| 
| =head1 NOTES
| 
| UNIX users without the 'env' prog must change the top line, to reflect
| the location of the perl executable matching the Config wanted, or else
| run the script by invoking the interpreter directly on the commandline.
| Win32 users should not have to worry about the #! line at all.
| 
| =head1 AUTHOR, CREDITS
| 
| Soren Andersen <somian -AT- cpan *DOT* org> is responsible for all
| badness.
| 
| Perl Monks "castaway" and "Aristotle" helped to point him towards
| solutions.
| 
| =cut
| 
| =begin gpg
| 
| -----BEGIN PGP SIGNATURE-----
| Version: GnuPG v1.0.6 (GNU/Linux)
| Comment: For info see http://www.gnupg.org
| 
| iD8DBQE/P5O0BXOj2U4kTqYRAvFsAKC/00foMSRX263oIdCDQLNuutPCXwCeOhU1
| FW4AgFpKJU57suWrrlM35g4=
| =Cwyp
| -----END PGP SIGNATURE-----
| 
| =end gpg

`----


-- 
Sooooo, tell me, my little one-eyed one: on what poor, pitiful, defenseless
planet has my MONSTROSITY been ... unleashed?
                     -- "Dr. Jumba" (Disney's "Lilo and Stitch")



Reply to: