1 package inc::latest::private;
5 $VERSION = eval $VERSION;
10 # must ultimately "goto" the import routine of the module to be loaded
11 # so that the calling package is correct when $mod->import() runs.
13 my ($package, $mod, @args) = @_;
14 my $file = $package->_mod2path($mod);
17 # Already loaded, but let _load_module handle import args
21 # A bundled copy must be present
22 my ($bundled, $bundled_dir) = $package->_search_bundled($file)
23 or die "No bundled copy of $mod found";
25 my $from_inc = $package->_search_INC($file);
27 # Only bundled is available
28 unshift(@INC, $bundled_dir);
32 if (_version($from_inc) >= _version($bundled)) {
33 # Ignore the bundled copy
37 # Load the bundled copy
38 unshift(@INC, $bundled_dir);
43 require ExtUtils::MakeMaker;
44 return ExtUtils::MM->parse_version(shift);
47 # use "goto" for import to preserve caller
49 my $package = shift; # remaining @_ is ready for goto
50 my ($mod, @args) = @_;
51 eval "require $mod; 1" or die $@;
52 if ( my $import = $mod->can('import') ) {
59 my ($self, $file) = @_;
63 local *DH; # Maintain 5.005 compatibility
64 opendir DH, $mypath or die "Can't open directory $mypath: $!";
66 while (defined(my $e = readdir DH)) {
67 next unless $e =~ /^inc_/;
68 my $try = File::Spec->catfile($mypath, $e, $file);
70 return($try, File::Spec->catdir($mypath, $e)) if -e $try;
75 # Look for the given path in @INC.
77 # TODO: doesn't handle coderefs or arrayrefs or objects in @INC, but
79 my ($self, $file) = @_;
81 foreach my $dir (@INC) {
83 my $try = File::Spec->catfile($dir, $file);
84 return $try if -e $try;
90 # Translate a module name into a directory/file.pm to search for in @INC
92 my ($self, $mod) = @_;
93 my @parts = split /::/, $mod;
95 return $parts[0] if @parts == 1;
96 return File::Spec->catfile(@parts);