Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.3 KiB

  1. package blib;
  2. =head1 NAME
  3. blib - Use MakeMaker's uninstalled version of a package
  4. =head1 SYNOPSIS
  5. perl -Mblib script [args...]
  6. perl -Mblib=dir script [args...]
  7. =head1 DESCRIPTION
  8. Looks for MakeMaker-like I<'blib'> directory structure starting in
  9. I<dir> (or current directory) and working back up to five levels of '..'.
  10. Intended for use on command line with B<-M> option as a way of testing
  11. arbitary scripts against an uninstalled version of a package.
  12. However it is possible to :
  13. use blib;
  14. or
  15. use blib '..';
  16. etc. if you really must.
  17. =head1 BUGS
  18. Pollutes global name space for development only task.
  19. =head1 AUTHOR
  20. Nick Ing-Simmons nik@tiuk.ti.com
  21. =cut
  22. use Cwd;
  23. use vars qw($VERSION);
  24. $VERSION = '1.00';
  25. sub import
  26. {
  27. my $package = shift;
  28. my $dir = getcwd;
  29. if ($^O eq 'VMS') { ($dir = VMS::Filespec::unixify($dir)) =~ s-/\z--; }
  30. if (@_)
  31. {
  32. $dir = shift;
  33. $dir =~ s/blib\z//;
  34. $dir =~ s,/+\z,,;
  35. $dir = '.' unless ($dir);
  36. die "$dir is not a directory\n" unless (-d $dir);
  37. }
  38. my $i = 5;
  39. while ($i--)
  40. {
  41. my $blib = "${dir}/blib";
  42. if (-d $blib && -d "$blib/arch" && -d "$blib/lib")
  43. {
  44. unshift(@INC,"$blib/arch","$blib/lib");
  45. warn "Using $blib\n";
  46. return;
  47. }
  48. $dir .= "/..";
  49. }
  50. die "Cannot find blib even in $dir\n";
  51. }
  52. 1;