Re: fetching module version from the command line

2006-07-17 Thread demerphq

On 7/17/06, A. Pagaltzis [EMAIL PROTECTED] wrote:

* Graham Barr [EMAIL PROTECTED] [2006-07-17 02:00]:
 perl -MDBI\ 999
 DBI version 999 required--this is only version 1.50.
 BEGIN failed--compilation aborted.

You can use an equals sign instead of a space, there, which makes
it a little easier to type:

perl -MDBI=666 -e1


Actually this only works correctly if the module uses Exporter.

The code translates to

use DBI qw(666);

which Exporter has special cased to DWIM. But if the module doesnt use
Exporter then it will be treated as an argument to import and not to
VERSION.

Yves

--
perl -Mre=debug -e /just|another|perl|hacker/


Re: fetching module version from the command line

2006-07-16 Thread Graham Barr
David Wheeler wrote:
 On Jul 12, 2006, at 03:41, Gabor Szabo wrote:
 
 perl -MModule -e'print $Module::VERSION'
 
 I have this alias set up:
 
   function pv () { perl -M$1 -le print $1-VERSION; }
 
 I think that calling -VERSION is more correct.

I am sure this discussion has happened in the past and in the archive
you could probably find what was suggested last time.

perl -MDBI\ 999
DBI version 999 required--this is only version 1.50.
BEGIN failed--compilation aborted.

Which is the same as writing

use DBI 999;

and perl will call DBI-VERSION(999);

Graham.




Re: fetching module version from the command line

2006-07-16 Thread A. Pagaltzis
* Graham Barr [EMAIL PROTECTED] [2006-07-17 02:00]:
 perl -MDBI\ 999
 DBI version 999 required--this is only version 1.50.
 BEGIN failed--compilation aborted.

You can use an equals sign instead of a space, there, which makes
it a little easier to type:

perl -MDBI=666 -e1

Regards,
-- 
#Aristotle
*AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(,$\/, )[defined wantarray]/e;$1};
Just-another-Perl-hacker;


Re: fetching module version from the command line

2006-07-16 Thread Andreas J. Koenig
 On Mon, 17 Jul 2006 02:24:37 +0200, A. Pagaltzis [EMAIL PROTECTED] 
 said:

   * Graham Barr [EMAIL PROTECTED] [2006-07-17 02:00]:
  perl -MDBI\ 999
  DBI version 999 required--this is only version 1.50.
  BEGIN failed--compilation aborted.

   You can use an equals sign instead of a space, there, which makes
   it a little easier to type:

   perl -MDBI=666 -e1

This is dangerous to believe, witness

% perl -Mstrict\ 999  
strict version 999 required--this is only version 1.03.
BEGIN failed--compilation aborted.
zsh: exit 9 perl -Mstrict\ 999
% perl -Mstrict=999 
Unknown 'strict' tag(s) '999' at - line 0
BEGIN failed--compilation aborted.
zsh: exit 9 perl -Mstrict=999


-- 
andreas


Re: fetching module version from the command line

2006-07-14 Thread Andreas J. Koenig
 On Thu, 13 Jul 2006 19:36:52 -0400, Randy W. Sims [EMAIL PROTECTED] 
 said:

   David Wheeler wrote:
  On Jul 13, 2006, at 05:56, Fergal Daly wrote:
  
  That's funny, it looks like I did put some code in to disable the END
  block if it's required rather than used. Turns out I did this to
  make MakeMaker happy, so MakeMaker does actually do a full require,
  Well, IIRC, both MakeMaker and Module::Build grep for the version
  line and eval that one line, but not the whole file. The CPAN
  indexer, OTOH, evals no code but just uses a regular expression
  search of the module file.

   Actually, I believe the CPAN indexer now uses META.yml whenever possible.

That's correct.

-- 
andreas


Re: fetching module version from the command line

2006-07-13 Thread Smylers
David Wheeler writes:

 On Jul 12, 2006, at 03:41, Gabor Szabo wrote:
 
 perl -MModule -e'print $Module::VERSION'
 
 I have this alias set up:
 
   function pv () { perl -M$1 -le print $1-VERSION; }

Along similar lines, I have this one-liner as ~/bin/pmv:

#! /bin/sh
perl -m$1 -le 'print '$1'-VERSION || die No VERSION in '$1'\n'

 I think that calling -VERSION is more correct.

So do I.  In fact I used to use $VERSION in my script, but changed to
-VERSION after some situation in which it worked and $VERSION didn't.
Sorry, I can't right now remember what that was.

Smylers


Re: fetching module version from the command line

2006-07-13 Thread Fergal Daly

On 12/07/06, Smylers [EMAIL PROTECTED] wrote:

David Wheeler writes:

 On Jul 12, 2006, at 03:41, Gabor Szabo wrote:

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

 I have this alias set up:

   function pv () { perl -M$1 -le print $1-VERSION; }

Along similar lines, I have this one-liner as ~/bin/pmv:

#! /bin/sh
perl -m$1 -le 'print '$1'-VERSION || die No VERSION in '$1'\n'

 I think that calling -VERSION is more correct.

So do I.  In fact I used to use $VERSION in my script, but changed to
-VERSION after some situation in which it worked and $VERSION didn't.
Sorry, I can't right now remember what that was.


These all fail for modules that do interesting things. For example
Test::NoWarnings performs a Test::Builder test in an END block to make
sure there were no warnings.

I could change it so that it tries to figure out whether it's being
used for real or not and disable the END block code but that's stress
and hassle. As a module author, as far as I'm concerned, if MakeMaker
can figure out my version then my job is done,

F


Re: fetching module version from the command line

2006-07-13 Thread H.Merijn Brand
On Thu, 13 Jul 2006 14:29:38 +0300, Gabor Szabo [EMAIL PROTECTED] wrote:

 On 7/13/06, Fergal Daly [EMAIL PROTECTED] wrote:
  I could change it so that it tries to figure out whether it's being
  used for real or not and disable the END block code but that's stress
  and hassle. As a module author, as far as I'm concerned, if MakeMaker
  can figure out my version then my job is done,
 
 So the only thing that would be correct is to search @INC for the .pm file
 and then grep it with the same regex MakeMaker uses.

Which is essentially waht bot V and MakeMaker do

-- 
H.Merijn BrandAmsterdam Perl Mongers (http://amsterdam.pm.org/)
using  porting perl 5.6.2, 5.8.x, 5.9.x  on HP-UX 10.20, 11.00, 11.11,
 11.23, SuSE 10.0, AIX 4.3  5.2, and Cygwin.   http://qa.perl.org
http://mirrors.develooper.com/hpux/   http://www.test-smoke.org
   http://www.goldmark.org/jeff/stupid-disclaimers/


Re: fetching module version from the command line

2006-07-13 Thread Smylers
Fergal Daly writes:

 On 12/07/06, Smylers [EMAIL PROTECTED] wrote:
 
  I have this one-liner as ~/bin/pmv:
  
  #! /bin/sh
  perl -m$1 -le 'print '$1'-VERSION || die No VERSION in '$1'\n'
 
 These all fail for modules that do interesting things. For example
 Test::NoWarnings performs a Test::Builder test in an END block to make
 sure there were no warnings.

So?  It still seems to work, for the purposes of determining what
version of the module is loaded:

  $ pmv Test::NoWarnings
  0.082

Smylers


Re: fetching module version from the command line

2006-07-13 Thread Fergal Daly

On 13/07/06, Smylers [EMAIL PROTECTED] wrote:

Fergal Daly writes:

 On 12/07/06, Smylers [EMAIL PROTECTED] wrote:

  I have this one-liner as ~/bin/pmv:
 
  #! /bin/sh
  perl -m$1 -le 'print '$1'-VERSION || die No VERSION in '$1'\n'

 These all fail for modules that do interesting things. For example
 Test::NoWarnings performs a Test::Builder test in an END block to make
 sure there were no warnings.

So?  It still seems to work, for the purposes of determining what
version of the module is loaded:

  $ pmv Test::NoWarnings
  0.082


That's funny, it looks like I did put some code in to disable the END
block if it's required rather than used. Turns out I did this to
make MakeMaker happy, so MakeMaker does actually do a full require,

F


Re: fetching module version from the command line

2006-07-13 Thread David Wheeler

On Jul 13, 2006, at 05:56, Fergal Daly wrote:


That's funny, it looks like I did put some code in to disable the END
block if it's required rather than used. Turns out I did this to
make MakeMaker happy, so MakeMaker does actually do a full require,


Well, IIRC, both MakeMaker and Module::Build grep for the version  
line and eval that one line, but not the whole file. The CPAN  
indexer, OTOH, evals no code but just uses a regular expression  
search of the module file.


Best,

David


Re: fetching module version from the command line

2006-07-13 Thread Yitzchak Scott-Thoennes
On Thu, Jul 13, 2006 at 02:29:38PM +0300, Gabor Szabo wrote:
 On 7/13/06, Fergal Daly [EMAIL PROTECTED] wrote:
 I could change it so that it tries to figure out whether it's being
 used for real or not and disable the END block code but that's stress
 and hassle. As a module author, as far as I'm concerned, if MakeMaker
 can figure out my version then my job is done,
 
 So the only thing that would be correct is to search @INC for the .pm file
 and then grep it with the same regex MakeMaker uses.

That wouldn't be correct for modules that aren't the one that determine
the distribution version, since other modules won't necessarily follow
the one-line rule.


Re: fetching module version from the command line

2006-07-13 Thread Randy W. Sims

David Wheeler wrote:

On Jul 13, 2006, at 05:56, Fergal Daly wrote:


That's funny, it looks like I did put some code in to disable the END
block if it's required rather than used. Turns out I did this to
make MakeMaker happy, so MakeMaker does actually do a full require,


Well, IIRC, both MakeMaker and Module::Build grep for the version line 
and eval that one line, but not the whole file. The CPAN indexer, OTOH, 
evals no code but just uses a regular expression search of the module file.


Actually, I believe the CPAN indexer now uses META.yml whenever possible.



fetching module version from the command line

2006-07-12 Thread Gabor Szabo

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'

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.

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.

Gabor


Re: fetching module version from the command line

2006-07-12 Thread Adriano Ferreira

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::Tagundef  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.


Re: fetching module version from the command line

2006-07-12 Thread H.Merijn Brand
On Wed, 12 Jul 2006 13:41:16 +0300, 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'

Not really reliable :) But the more reliable ways take some post-processing

pc09:/home/merijn 108  perl -le'require V;print V::get_version(DBI)'
1.51
pc09:/home/merijn 109  perl -MExtUtils::Installed -le'print 
ExtUtils::Installed-new-version(DBI)'
1.51
pc09:/home/merijn 110  perl -MV=DBI
DBI
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/DBI.pm: 1.51
pc09:/home/merijn 111  perl -le'require V;print V::get_version(DBI)' 
1.51
pc09:/home/merijn 112  perl -MDBI=99
DBI version 99 required--this is only version 1.51 at 
/pro/lib/perl5/5.8.7/Exporter/Heavy.pm line 121.
BEGIN failed--compilation aborted.
Exit 9
pc09:/home/merijn 113 

V is not (yet) on CPAN: http://www.test-smoke.org/otherperl.html

 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.
 
 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.


-- 
H.Merijn BrandAmsterdam Perl Mongers (http://amsterdam.pm.org/)
using  porting perl 5.6.2, 5.8.x, 5.9.x  on HP-UX 10.20, 11.00, 11.11,
 11.23, SuSE 10.0, AIX 4.3  5.2, and Cygwin.   http://qa.perl.org
http://mirrors.develooper.com/hpux/   http://www.test-smoke.org
   http://www.goldmark.org/jeff/stupid-disclaimers/


Re: fetching module version from the command line

2006-07-12 Thread Rafael Garcia-Suarez
Gabor Szabo wrote in perl.qa :
 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'

You should probably use -mModule to avoid calling Module::import().
(also, in some pathological cases, one can imagine that
UNIVERSAL::VERSION() has been overidden)

Side note:
Abe Timmerman has a module, V, useful to get versions
of installed modules:
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2006-03/msg01038.html


Re: fetching module version from the command line

2006-07-12 Thread David Wheeler

On Jul 12, 2006, at 03:41, Gabor Szabo wrote:


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


I have this alias set up:

  function pv () { perl -M$1 -le print $1-VERSION; }

I think that calling -VERSION is more correct.

Best,

David