Initial bulk commit for "Git on MSys"
[msysgit/historical-msysgit.git] / lib / perl5 / 5.6.1 / blib.pm
blob0916f797fd11f0f9df10cd32aa97f81de8a45805
1 package blib;
3 =head1 NAME
5 blib - Use MakeMaker's uninstalled version of a package
7 =head1 SYNOPSIS
9 perl -Mblib script [args...]
11 perl -Mblib=dir script [args...]
13 =head1 DESCRIPTION
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 arbitary scripts against an uninstalled version of a package.
21 However it is possible to :
23 use blib;
24 or
25 use blib '..';
27 etc. if you really must.
29 =head1 BUGS
31 Pollutes global name space for development only task.
33 =head1 AUTHOR
35 Nick Ing-Simmons nik@tiuk.ti.com
37 =cut
39 use Cwd;
41 use vars qw($VERSION);
42 $VERSION = '1.00';
44 sub import
46 my $package = shift;
47 my $dir = getcwd;
48 if ($^O eq 'VMS') { ($dir = VMS::Filespec::unixify($dir)) =~ s-/\z--; }
49 if (@_)
51 $dir = shift;
52 $dir =~ s/blib\z//;
53 $dir =~ s,/+\z,,;
54 $dir = '.' unless ($dir);
55 die "$dir is not a directory\n" unless (-d $dir);
57 my $i = 5;
58 while ($i--)
60 my $blib = "${dir}/blib";
61 if (-d $blib && -d "$blib/arch" && -d "$blib/lib")
63 unshift(@INC,"$blib/arch","$blib/lib");
64 warn "Using $blib\n";
65 return;
67 $dir .= "/..";
69 die "Cannot find blib even in $dir\n";