5 blib - Use MakeMaker's uninstalled version of a package
9 perl -Mblib script [args...]
11 perl -Mblib=dir script [args...]
15 Looks for MakeMaker-like I<'blib'> directory structure starting in
16 I<dir> (or current directory) and working back up to five levels of '..'.
18 Intended for use on command line with B<-M> option as a way of testing
19 arbitrary scripts against an uninstalled version of a package.
21 However it is possible to :
27 etc. if you really must.
31 Pollutes global name space for development only task.
35 Nick Ing-Simmons nik@tiuk.ti.com
42 use vars qw($VERSION $Verbose);
50 if ($^O eq "MSWin32" && -f "Win32.xs") {
51 # We don't use getcwd() on Windows because it will internally
52 # call Win32::GetCwd(), which will get the Win32 module loaded.
53 # That means that it would not be possible to run `make test`
54 # for the Win32 module because blib.pm would always load the
55 # installed version before @INC gets updated with the blib path.
61 if ($^O eq 'VMS') { ($dir = VMS::Filespec::unixify($dir)) =~ s-/\z--; }
67 $dir = File::Spec->curdir unless ($dir);
68 die "$dir is not a directory\n" unless (-d $dir);
71 # detaint: if the user asked for blib, s/he presumably knew
73 $dir = $1 if $dir =~ /^(.*)$/;
76 my($blib, $blib_lib, $blib_arch);
79 $blib = File::Spec->catdir($dir, "blib");
80 $blib_lib = File::Spec->catdir($blib, "lib");
81 $blib_arch = File::Spec->catdir($blib, "arch");
83 if (-d $blib && -d $blib_arch && -d $blib_lib)
85 unshift(@INC,$blib_arch,$blib_lib);
86 warn "Using $blib\n" if $Verbose;
89 $dir = File::Spec->catdir($dir, File::Spec->updir);
91 die "Cannot find blib even in $dir\n";