PDLA-Core

 view release on metacpan or  search on metacpan

Basic/AutoLoader.pm  view on Meta::CPAN

    }
  } else {
    print "AutoLoader: no NiceSlice...\n" if($PDLA::debug);
    do $file;
  }
}


# Expand directories recursively...
sub PDLA::AutoLoader::expand_dir {
  local $d;  
  local @list;  
  local @subdirs;  

  local $dir = shift;
    
  if(! -d $dir) { return undef; }
  push(@list,$dir);

  opendir(FOO,$dir);

  @subdirs = grep((!m/^\./ && ($_="$dir/$_") && (-d $_)), readdir(FOO));
  closedir FOO;

  while(defined ($d = shift @subdirs)) {
    push(@list,&PDLA::AutoLoader::expand_dir($d));
  }
  return @list;
}


=head2 PDLA::AutoLoader::expand_path

=for ref 

Expand a compactified path into a dir list

You supply a pathlist and leading '+' and '~' characters get expanded into
full directories.  Normally you don't want to use this -- it's internal to the
autoloader -- but some utilities, like the online documentation searcher, need
to be able to use it.

=cut

sub PDLA::AutoLoader::expand_path {
    my @PDLALIB = @_;
    my @PDLALIB_EXPANDED;
    
    print "AutoLoader: Expanding directories from ".join(':',@PDLALIB)."...\n"
	if($PDLA::debug);
    local $_;
    foreach $_(@PDLALIB) {
	# Expand ~{name} and ~ conventions.
	if(s/^(\+?)\~(\+||[a-zA-Z0-9]*)//) {
	    if($2 eq '+') {
		# Expand shell '+' to CWD.
		$_= $1 . ($ENV{'PWD'} || '.');
	    } elsif(!$2) {
		# No name mentioned -- use current user.
                #   Ideally would use File::HomeDir->my_home() here
		$_ = $1 . ( $ENV{'HOME'} || (( getpwnam( getlogin || getpwuid($<) ))[7]) )  . $_;
	    } else {
		# Name mentioned - try to get that user's home directory.
		$_ = $1 . ( (getpwnam($2))[7] ) . $_;
	    }
	}
	
	# If there's a leading '+', include all subdirs too.
	push(@PDLALIB_EXPANDED,
	     s/^\+// ? &PDLA::AutoLoader::expand_dir($_) : $_
	     );
    }

    print "AutoLoader: returning ",join(",",@PDLALIB_EXPANDED),"\n" if($PDLA::debug);
    @PDLALIB_EXPANDED;
}


;# Exit with OK status

1;



( run in 0.871 second using v1.01-cache-2.11-cpan-2398b32b56e )