in reply to Figuring out which version of a loaded module

use MyModule; print MyModule->VERSION;

Replies are listed 'Best First'.
Re: Re: Figuring out which version of a loaded module
by dragonchild (Archbishop) on Feb 26, 2003 at 15:54 UTC
    I want to find out if MyModule is at least version N. I don't want to parse the version strings. I'll let VERSION do that for me. :-)

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

      if you supply a number to UNIVERSAL::VERSION like you do, it simply does a numeric compare.

      So your exact script could be reduced to:

      $self->{PDF_VERSION} = int pdflib_pl->VERSION or die "Cannot find pdflib_pl version\n"; $self->{PDF_VERSION} = 4 if $self->{PDF_VERSION} > 4;

      •Update: OK, correction, if $pdflib_pl::VERSION is a v-string it messes up, but I have never seen a module that uses that (none of the core modules are, nor are the tons of other modules installed on my computer).

      In fact, perldoc perlmodlib and perlmodstyle actually says explicitly $VERSION should be a floating-point number.