This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Extraneous blank lines from Pod::Text
[perl5.git] / lib / blib.pm
1 package blib;
2
3 =head1 NAME
4
5 blib - Use MakeMaker's uninstalled version of a package
6
7 =head1 SYNOPSIS
8
9  perl -Mblib script [args...]
10
11  perl -Mblib=dir script [args...]
12
13 =head1 DESCRIPTION
14
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 '..'.
17
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.
20
21 However it is possible to : 
22
23  use blib; 
24  or 
25  use blib '..';
26
27 etc. if you really must.
28
29 =head1 BUGS
30
31 Pollutes global name space for development only task.
32
33 =head1 AUTHOR
34
35 Nick Ing-Simmons nik@tiuk.ti.com
36
37 =cut 
38
39 use Cwd;
40
41
42 sub import
43 {
44  my $package = shift;
45  my $dir = getcwd;
46  if (@_)
47   {
48    print join(',',@_),"\n";
49    $dir = shift;
50    $dir =~ s/blib$//;
51    $dir =~ s,/+$,,;
52    $dir = '.' unless ($dir);
53    die "$dir is not a directory\n" unless (-d $dir);
54   }
55  my $i   = 5;
56  while ($i--)
57   {
58    my $blib = "${dir}/blib";
59    if (-d $blib && -d "$blib/arch" && -d "$blib/lib")
60     {
61      unshift(@INC,"$blib/arch","$blib/lib");
62      warn "Using $blib\n";
63      return;
64     }
65    $dir .= "/..";
66   }
67  die "Cannot find blib even in $dir\n";
68 }
69
70 1;