Rob Dixon wrote:
[...]
All it does is to put some stub code in place of any missing modules, with an
import routine that just pushes the name of the package onto array
@main::NOTFOUND. Then the CHECK block code just reports the contents of that
array and dies if it's not empty.

There are a number of issues with it, such as it only detecting missing modules
that have had their import routine called, but that's what use does anyway.
There are also probably others, but it's a start. See how you get on with it.

Hello,
I tried to understand what you wrote to me, reading perl docs but I have still a lot (too many) of doubts. I adapted your code below to what I need but there are stil things I dont' understand and so I'm here again to ask. First of all I don't understand how the @_ contains all the not found modules.
Where they are coming from ? @_ contains the sub incoming parameters.
But why are these only the unresolved modules (and not only: I'll explain later) ?

Does the push @INC, statement modifies the @INC array ? I traced it before and after and I noticed no changes. It reports also some errors on xxxx.al files. It seems that I use not properly some methods of some widgets.
For example: I use this delete method
   $tree->delete('all');
where $tree is created as:
my $tree = $left_fr->Scrolled('Tree')->pack(-expand => 1, -fill => 'both');
I got:
syntax error at /loader/0x9964f24//usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/Tk/Frame/delete.al line 2, near "package ::usr::lib::perl5::site_perl::5.8.5" Compilation failed in require at /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/Tk/Widget.pm line301.
at ./test.pl line 417

Why this ?

Thank you in advance

Francesco

HTH,

Rob


use strict;
use warnings;

our @NOTFOUND;

BEGIN {
  push @INC, sub {

    my ($self, $package) = @_;
    $package =~ s#/#::#g;
    $package =~ s#\.pm$##;

    my $module = qq{
      package $package;
      sub import { push [EMAIL PROTECTED]::NOTFOUND, '$package'; }
      1;
    };

    open my $fh, '<', \$module;
    return $fh;
  }
}

CHECK {
  if (@NOTFOUND) {
    die "Modules not installed: ". join ', ', @NOTFOUND;
  }
}



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to