Code Comments
Programming Forum and web based access to our favorite programming groups.I'm trying to find the version number of the CPAN modules I've
installed so I can keep my modules up to date. The following script
shows the technique I've tried:
#!/usr/bin/perl
use strict;
use warnings FATAL=>'all';
for (qw/Text::Table Class::DBI::Loader::GraphViz/)
{
print "$_: /", fetch_installed_version($_), "/\n";
}
sub fetch_installed_version
{
my $pkg = shift;
eval "require $pkg";
my $iver = eval '$'."${pkg}::VERSION";
die "VERSION is not defined in $pkg\n"
unless $iver;
return $iver;
}
The script gets the version for Text::Table but not for
Class::DBI::Loader::GraphViz:
Text::Table: /1.107/
VERSION is not defined in Class::DBI::Loader::GraphViz
This isn't a one off, about a third of the packages produce the same
error.
If I try to get the version from the command line, I get:
zippy:~/scripts$ perl -MClass::DBI::Loader::GraphViz -we \
'print $Class::DBI::Loader::GraphViz::VERSION'
Base class package "GraphViz::DBI" is empty.
(Perhaps you need to 'use' the module which defines that
package first.)
at /usr/share/perl5/Class/DBI/Loader/GraphViz.pm line 3
BEGIN failed--compilation aborted at
/usr/share/perl5/Class/DBI/Loader/GraphViz.pm line 3.
Compilation failed in require.
BEGIN failed--compilation aborted.
ISTM that my technique is flawed, so what is the best way to find a
module's $VERSION programmatically?
Post Follow-up to this messageBrian Greenfield <$news\200101$@zombie.org.uk> wrote in comp.lang.perl.misc:
> I'm trying to find the version number of the CPAN modules I've
> installed so I can keep my modules up to date.
You get this functionality from CPANPLUS (not sure if the predecessor
CPAN already had it). It compares versions of installed modules with
current versions on CPAN.
> The following script
> shows the technique I've tried:
>
> #!/usr/bin/perl
>
> use strict;
> use warnings FATAL=>'all';
>
> for (qw/Text::Table Class::DBI::Loader::GraphViz/)
> {
> print "$_: /", fetch_installed_version($_), "/\n";
> }
>
> sub fetch_installed_version
> {
> my $pkg = shift;
>
> eval "require $pkg";
> my $iver = eval '$'."${pkg}::VERSION";
> die "VERSION is not defined in $pkg\n"
> unless $iver;
> return $iver;
> }
>
> The script gets the version for Text::Table but not for
> Class::DBI::Loader::GraphViz:
>
> Text::Table: /1.107/
> VERSION is not defined in Class::DBI::Loader::GraphViz
>
> This isn't a one off, about a third of the packages produce the same
> error.
>
> If I try to get the version from the command line, I get:
>
> zippy:~/scripts$ perl -MClass::DBI::Loader::GraphViz -we \
> 'print $Class::DBI::Loader::GraphViz::VERSION'
> Base class package "GraphViz::DBI" is empty.
> (Perhaps you need to 'use' the module which defines that
> package first.)
> at /usr/share/perl5/Class/DBI/Loader/GraphViz.pm line 3
> BEGIN failed--compilation aborted at
> /usr/share/perl5/Class/DBI/Loader/GraphViz.pm line 3.
> Compilation failed in require.
> BEGIN failed--compilation aborted.
>
> ISTM that my technique is flawed, so what is the best way to find a
> module's $VERSION programmatically?
There is no formal requirement for a CPAN module to have a version.
Modules that are part of a larger distribution often don't have a
version of their own. Class::DBI::Loader::GraphViz could be one
of those.
For an alternative (but not fundamentally different) approach to
version reading look at base.pm.
Anno
Post Follow-up to this messageOn 30 Oct 2004 15:15:34 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote: >Brian Greenfield <$news\200101$@zombie.org.uk> wrote in comp.lang.perl.mis c: > >You get this functionality from CPANPLUS (not sure if the predecessor >CPAN already had it). It compares versions of installed modules with >current versions on CPAN. Noted. [Script snipped] ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^[col or=darkred] I should have read the error message more carefully. Doh! ISTM that my brain is flawed:( After a couple of hours away from the problem, the solution became clear: make sure I have all the module dependencies installed >For an alternative (but not fundamentally different) approach to >version reading look at base.pm. Will do. Thanks.
Post Follow-up to this message"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message news:cm0b6m$89m$1@mamenchi.zrz.TU-Berlin.DE... > Brian Greenfield <$news\200101$@zombie.org.uk> wrote in comp.lang.perl.misc: > > You get this functionality from CPANPLUS (not sure if the predecessor > CPAN already had it). It compares versions of installed modules with > current versions on CPAN. > CPAN.pm does indeed offer this functionality, with the 'r' command from the CPAN shell. It will give a list of your currently installed modules that are less up-to-date than the versions currently available on the CPAN. (Note that - I believe unlike CPANPLUS - there is no functionality to automatically download and install the newer versions based on this list). Paul Lalli
Post Follow-up to this messageAlso sprach Paul Lalli:
> "Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
> news:cm0b6m$89m$1@mamenchi.zrz.TU-Berlin.DE...
> comp.lang.perl.misc:
>
> CPAN.pm does indeed offer this functionality, with the 'r' command from th
e
> CPAN shell. It will give a list of your currently installed modules that
> are less up-to-date than the versions currently available on the CPAN.
> (Note that - I believe unlike CPANPLUS - there is no functionality to
> automatically download and install the newer versions based on this list).
There is, although no obvious way: You create a bundle with
'autobundle', make sure the newly created file is in @INC and then do a
'install Bundle::Snapshot_<DATE>.pm'
That works best if you have the latest perl installed, otherwise it will
try to grab and compile a new perl.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{re
htonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.