On 7/12/06, Gabor Szabo <[EMAIL PROTECTED]> wrote:
While checking if the versions of all the modules are as
required in our installation I am using the following one liner to
fetch the version numbers.

perl -MModule -e'print $Module::VERSION'

This one-liner doesn't work all the time in modules with deep magic
(filters and modules which do strange/heavy things in BEGIN blocks,
POD-only modules and the like). A (text-based) alternative is the
ExtUtils::MakeMaker approach, which goes as follows:

perl -MExtUtils::MakeMaker -e 'print MM->parse_version(shift)'
/usr/lib/perl5/site_perl/5.8/Module.pm

Unfortunately, it depends on knowing where the .pm file is. But that
can be arranged.

Some of the modules print extra error messages and some print
only error messages.
I have sent e-mail to the respective module authors reporting this
issue but I wonder if it would this a good practice in the genric case.

I think that having version numbers is a good practice. Although to
demand they may be retrieved with "perl -MModule -e 'print
$Module::VERSION'" may be too much - don't forget that it means the
module should compile and certain modules may demand a bunch of
environment settings to do it (the right libraries, some bit of
configuration, etc.)

Is there a Test module that test just the above?
Is the a CPANST score one can get if all the modules in a distro
provide the correct version information and if they don't print anything
else to STDOUT or STDERR.

I think a test to check version numbers are provided is enough.
Another issue is that use_ok() (or some variant) works too (in a
silent fashion). As a matter of fact, the absence of version numbers
is very common for modules which are not the ones that provide the
version number for a CPAN distribution - you may see this at many
places: core modules and many others. For example, trying the YAML::*
modules installed in a Cygwin machine with which_pm (from Module-Which
distribution) gives me (module name, version, location):

$ which_pm YAML:: --p5p
YAML::Syck           0.45       at ${installsitearch}/
YAML::Loader::Syck   undef      at ${installsitearch}/
YAML::Dumper::Syck   undef      at ${installsitearch}/
YAML::Transfer       undef      at ${installsitelib}/
YAML::Family         undef      at ${installsitelib}/
YAML::Node           undef      at ${installsitelib}/
YAML::Marshall       undef      at ${installsitelib}/
YAML::Tag            undef      at ${installsitelib}/
YAML::Base           undef      at ${installsitelib}/
YAML::Types          undef      at ${installsitelib}/
YAML::Loader         undef      at ${installsitelib}/
YAML::Error          undef      at ${installsitelib}/
YAML::Dumper         undef      at ${installsitelib}/
YAML::Tiny           0.05       at ${installsitelib}/
YAML::Loader::Base   undef      at ${installsitelib}/
YAML::Dumper::Base   undef      at ${installsitelib}/

from Config:
       installsitearch: /usr/lib/perl5/site_perl/5.8/cygwin
       installsitelib: /usr/lib/perl5/site_perl/5.8

Adriano.

Reply via email to