1*0Sstevel@tonic-gatepackage blib; 2*0Sstevel@tonic-gate 3*0Sstevel@tonic-gate=head1 NAME 4*0Sstevel@tonic-gate 5*0Sstevel@tonic-gateblib - Use MakeMaker's uninstalled version of a package 6*0Sstevel@tonic-gate 7*0Sstevel@tonic-gate=head1 SYNOPSIS 8*0Sstevel@tonic-gate 9*0Sstevel@tonic-gate perl -Mblib script [args...] 10*0Sstevel@tonic-gate 11*0Sstevel@tonic-gate perl -Mblib=dir script [args...] 12*0Sstevel@tonic-gate 13*0Sstevel@tonic-gate=head1 DESCRIPTION 14*0Sstevel@tonic-gate 15*0Sstevel@tonic-gateLooks for MakeMaker-like I<'blib'> directory structure starting in 16*0Sstevel@tonic-gateI<dir> (or current directory) and working back up to five levels of '..'. 17*0Sstevel@tonic-gate 18*0Sstevel@tonic-gateIntended for use on command line with B<-M> option as a way of testing 19*0Sstevel@tonic-gatearbitary scripts against an uninstalled version of a package. 20*0Sstevel@tonic-gate 21*0Sstevel@tonic-gateHowever it is possible to : 22*0Sstevel@tonic-gate 23*0Sstevel@tonic-gate use blib; 24*0Sstevel@tonic-gate or 25*0Sstevel@tonic-gate use blib '..'; 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gateetc. if you really must. 28*0Sstevel@tonic-gate 29*0Sstevel@tonic-gate=head1 BUGS 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gatePollutes global name space for development only task. 32*0Sstevel@tonic-gate 33*0Sstevel@tonic-gate=head1 AUTHOR 34*0Sstevel@tonic-gate 35*0Sstevel@tonic-gateNick Ing-Simmons nik@tiuk.ti.com 36*0Sstevel@tonic-gate 37*0Sstevel@tonic-gate=cut 38*0Sstevel@tonic-gate 39*0Sstevel@tonic-gateuse Cwd; 40*0Sstevel@tonic-gateuse File::Spec; 41*0Sstevel@tonic-gate 42*0Sstevel@tonic-gateuse vars qw($VERSION $Verbose); 43*0Sstevel@tonic-gate$VERSION = '1.02'; 44*0Sstevel@tonic-gate$Verbose = 0; 45*0Sstevel@tonic-gate 46*0Sstevel@tonic-gatesub import 47*0Sstevel@tonic-gate{ 48*0Sstevel@tonic-gate my $package = shift; 49*0Sstevel@tonic-gate my $dir = getcwd; 50*0Sstevel@tonic-gate if ($^O eq 'VMS') { ($dir = VMS::Filespec::unixify($dir)) =~ s-/\z--; } 51*0Sstevel@tonic-gate if (@_) 52*0Sstevel@tonic-gate { 53*0Sstevel@tonic-gate $dir = shift; 54*0Sstevel@tonic-gate $dir =~ s/blib\z//; 55*0Sstevel@tonic-gate $dir =~ s,/+\z,,; 56*0Sstevel@tonic-gate $dir = File::Spec->curdir unless ($dir); 57*0Sstevel@tonic-gate die "$dir is not a directory\n" unless (-d $dir); 58*0Sstevel@tonic-gate } 59*0Sstevel@tonic-gate my $i = 5; 60*0Sstevel@tonic-gate my($blib, $blib_lib, $blib_arch); 61*0Sstevel@tonic-gate while ($i--) 62*0Sstevel@tonic-gate { 63*0Sstevel@tonic-gate $blib = File::Spec->catdir($dir, "blib"); 64*0Sstevel@tonic-gate $blib_lib = File::Spec->catdir($blib, "lib"); 65*0Sstevel@tonic-gate 66*0Sstevel@tonic-gate if ($^O eq 'MacOS') 67*0Sstevel@tonic-gate { 68*0Sstevel@tonic-gate $blib_arch = File::Spec->catdir($blib_lib, $MacPerl::Architecture); 69*0Sstevel@tonic-gate } 70*0Sstevel@tonic-gate else 71*0Sstevel@tonic-gate { 72*0Sstevel@tonic-gate $blib_arch = File::Spec->catdir($blib, "arch"); 73*0Sstevel@tonic-gate } 74*0Sstevel@tonic-gate 75*0Sstevel@tonic-gate if (-d $blib && -d $blib_arch && -d $blib_lib) 76*0Sstevel@tonic-gate { 77*0Sstevel@tonic-gate unshift(@INC,$blib_arch,$blib_lib); 78*0Sstevel@tonic-gate warn "Using $blib\n" if $Verbose; 79*0Sstevel@tonic-gate return; 80*0Sstevel@tonic-gate } 81*0Sstevel@tonic-gate $dir = File::Spec->catdir($dir, File::Spec->updir); 82*0Sstevel@tonic-gate } 83*0Sstevel@tonic-gate die "Cannot find blib even in $dir\n"; 84*0Sstevel@tonic-gate} 85*0Sstevel@tonic-gate 86*0Sstevel@tonic-gate1; 87