1N/Apackage blib;
1N/A
1N/A=head1 NAME
1N/A
1N/Ablib - Use MakeMaker's uninstalled version of a package
1N/A
1N/A=head1 SYNOPSIS
1N/A
1N/A perl -Mblib script [args...]
1N/A
1N/A perl -Mblib=dir script [args...]
1N/A
1N/A=head1 DESCRIPTION
1N/A
1N/ALooks for MakeMaker-like I<'blib'> directory structure starting in
1N/AI<dir> (or current directory) and working back up to five levels of '..'.
1N/A
1N/AIntended for use on command line with B<-M> option as a way of testing
1N/Aarbitary scripts against an uninstalled version of a package.
1N/A
1N/AHowever it is possible to :
1N/A
1N/A use blib;
1N/A or
1N/A use blib '..';
1N/A
1N/Aetc. if you really must.
1N/A
1N/A=head1 BUGS
1N/A
1N/APollutes global name space for development only task.
1N/A
1N/A=head1 AUTHOR
1N/A
1N/ANick Ing-Simmons nik@tiuk.ti.com
1N/A
1N/A=cut
1N/A
1N/Ause Cwd;
1N/Ause File::Spec;
1N/A
1N/Ause vars qw($VERSION $Verbose);
1N/A$VERSION = '1.02';
1N/A$Verbose = 0;
1N/A
1N/Asub import
1N/A{
1N/A my $package = shift;
1N/A my $dir = getcwd;
1N/A if ($^O eq 'VMS') { ($dir = VMS::Filespec::unixify($dir)) =~ s-/\z--; }
1N/A if (@_)
1N/A {
1N/A $dir = shift;
1N/A $dir =~ s/blib\z//;
1N/A $dir =~ s,/+\z,,;
1N/A $dir = File::Spec->curdir unless ($dir);
1N/A die "$dir is not a directory\n" unless (-d $dir);
1N/A }
1N/A my $i = 5;
1N/A my($blib, $blib_lib, $blib_arch);
1N/A while ($i--)
1N/A {
1N/A $blib = File::Spec->catdir($dir, "blib");
1N/A $blib_lib = File::Spec->catdir($blib, "lib");
1N/A
1N/A if ($^O eq 'MacOS')
1N/A {
1N/A $blib_arch = File::Spec->catdir($blib_lib, $MacPerl::Architecture);
1N/A }
1N/A else
1N/A {
1N/A $blib_arch = File::Spec->catdir($blib, "arch");
1N/A }
1N/A
1N/A if (-d $blib && -d $blib_arch && -d $blib_lib)
1N/A {
1N/A unshift(@INC,$blib_arch,$blib_lib);
1N/A warn "Using $blib\n" if $Verbose;
1N/A return;
1N/A }
1N/A $dir = File::Spec->catdir($dir, File::Spec->updir);
1N/A }
1N/A die "Cannot find blib even in $dir\n";
1N/A}
1N/A
1N/A1;