Re: Check for modules presence



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 \@main::NOTFOUND, '$package'; }
1;
};

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

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


.



Relevant Pages

  • Re: C bindings, Interfaces.C.Pointers etc.
    ... standard array notation. ... I have used a generic package to create the appropriate ... pragma Convention; ... end CArrayUtils; ...
    (comp.lang.ada)
  • Re: Accessing data in embedded class object WMI ACPI sample from DDK
    ... set the properties of a Package class object. ... as it's property an array. ... execute the SetPackage or GetPackage methods but am confused about how to ... > const BSTR PackageInst = ...
    (microsoft.public.win32.programmer.wmi)
  • Re: Packages and returning errors
    ... The perldoc function guide says about shift (which is ... "Shifts the first value of the array off and returns it, ... If an array of values are passed to a sub, ... Back to my package (which I am currently thinking might be out of my depth, ...
    (comp.lang.perl.misc)
  • Unconstrained array of unconstrained vector.
    ... Is there a way (in VHDL93) to define an array of vectors in a package ... The advantage is having a set of packages with self contained routines ...
    (comp.lang.vhdl)
  • Re: file copy routine crashes on XP SP2
    ... copy/paste/experiment merchant when it comes to API stuff), ... method seems pretty comon in VB6 code sites. ... Anyway, the routine has ... the new package) This is a bit drastic, ...
    (microsoft.public.vb.general.discussion)