On Tue, 30 Oct 2001 00:21:10 +0100, Axel Rose wrote:

>This step is necessary for a standalone builder where all modules are
>put into the TEXT resource of a standalone program. The current
>RuntimeBuilder, originally written by Michael Ziege and greatly enhanced
>by Keitarou Miyazaki, lacks this ability. Now standalone MacPerl
>programs may therefore stop with messages about missing modules.

I'll look into it later; but just for now, I can only say "me too!". I
made such a script myself; or better: I made modifications to the
RuntimeBuilder droplet, so it included this functionality. I've attached
my additions, so you can compare.

>The idea is to go through the source file, find its "use" and "require"
>lines, eval them and fill %INC. In a second loop I go through every
>entry of %INC search for further "require" statements, check if the then
>required files containes another "require" and so on and on until %INC
>doesn't grow anymore.

That's pretty much how I did it , too. However: my stuff is pretty
compact. I wonder if you haven't worked much too hard.  ;-)

Here's it all, the whole BEGIN block, replacing the one that was there.

BEGIN {
    exit unless @ARGV;

    #suppress warnings about redefining subroutines
    #by 'eval(use...)':
    local $^W;
    
    print "Checking for imported modules...\n";
# START OF BART'S MODIFICATIONS
    my @modules = $ARGV[0];
    my %inc;
    while(my $source = shift @modules) {
        open FILE, $source or die "Couldn't open file $source: $!";
        while (<FILE>) {
            if(/^\s*(use|require)\b.*;/){
                eval($_); #read the %INC
            }
        }
        close FILE;
        foreach my $path (values %INC) {
            $inc{$path}++ or push @modules, $path;
        }
    }
# END OF BART'S MODIFICATIONS
    %MyINC = %INC;
    @dynaLoaderModules = @DynaLoader::dl_modules;
}

-- 
        Bart.

Reply via email to