G DynamicLoader
SummaryIncluded librariesPackage variablesDescriptionGeneral documentation
Summary
    G::DynamicLoader - Dynamic Loading of Plug-in modules
Package variables
No package variables defined.
Included modules
File::Find
Inherit
Exporter
Synopsis
No synopsis!
Description
    This class is a part of G-language Genome Analysis Environment, 
    for internal functionality of dynamically loading plug-in modules.

    G-language System searches for plug-in modules located at 
    ~/Plug-in or $ENV{GLANG_PLUGIN} at compile time, and exports 
    all EXPORTed methods in any depths of folders within the plug-in 
    directory. Therefore, users can customize and override the
    installed G-language modules by placing the custom module 
    in their plug-in folder with the same class name and method name.
Methods
Methods description
None available.
Methods code
BEGINTop
BEGIN {
    my $path = $ENV{HOME} . '/Plug-in';
    if($ENV{GLANG_PLUGIN}){
	$path = $ENV{GLANG_PLUGIN};
	substr($path, -1, 1) = '' if(substr($path, -1, 1) eq '/');
    }
    unshift(@INC, $path);

    no strict 'refs';
    
    my $sub = sub {
	my $dir = $File::Find::name;
	my $dirpath = $dir;
	
	if(-d $dir){
	    $dir =~ s/^$path$/\.\//g;
	    $dir =~ s/^$path\//\.\//g;
	    
	    my $file;
	    opendir(DIR, $dirpath) || die "can't opendir $dir: $!"; 
	    
	    $dir =~ s/^\.\//\.::/g;
	    $dir.="::" unless($dir=~/::$/);
	    $dir =~ s/\//::/g;	
	    $dir =~ s/^\.:://g;	
	    
	    while(defined($file=readdir(DIR))){
		if($file=~/(.+)\.pm$/){
		    next if ($file =~ /^\.\#/);
		    my $dirname = $dir . $1;

		    eval "use $dirname";
		    warn "$@" if ($@);
		    
		    push(@EXPORT, @{$dirname . '::' . 'EXPORT'});	   
		}
	    }
	    closedir(DIR);
	}
    };
    
    find($sub, $path) if (-e $path);
}
No methods available.
General documentation
No general documentation available.