develooper Front page | perl.perl5.porters | Postings from April 2006

Re: [PATCH] Add V.pm to the core

Thread Previous | Thread Next
From:
Yitzchak Scott-Thoennes
Date:
April 4, 2006 01:01
Subject:
Re: [PATCH] Add V.pm to the core
Message ID:
20060404080052.GA3300@efn.org
On Fri, Mar 31, 2006 at 10:05:16PM +0200, Johan Vromans wrote:
> Abe Timmerman <abe@ztreet.demon.nl> writes:
> 
> >     Can now also be used as a light-weight module for getting versions of
> >     modules without loading them:
> 
> What would be the version of this module:
> 
>     package Foo;
> 
>     $VERSION = 1;
> 
>     $VERSION++;
> 
>     if ( -s "/etc/passwd" == 2011 ) {
>         $VERSION *=2;
>     }
> 
>     1;
> 
> Hint: Perl claims the version is 2 or 4, depending on your
> /etc/passwd.
> 
> Disclaimer: I didn't invent this.

There's a need to differentiate between VERSION as determinable without
loading the module and VERSION as it is if you do load it.  If you want
reliable results from the former, you (the module author) are going to
have to limit how you set it.

Other simple examples of VERSION being different if you actually load
the module are the common:

   $VERSION = "1.23_01";
   $VERSION = eval $VERSION;

or even:

   sub VERSION {
      die __PACKAGE__ . " version $_[1] required--this is only version 3.14"
         if @_ > 1 && $_[1] > 3.14;
      "3.14"
   }

(There's no actual requirement to use a $VERSION variable except on
behalf of tools that need the VERSION without loading the module.)

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About