hesco has asked for the wisdom of the Perl Monks concerning the following question:

Today, I've been learning how to build a package ready for distribution, with the help of Joost who responded on this thread.

I've been reworking a configuration module to fit inside the Best Practices framework provided by Module::Starter. When I installed Module::Starter::PBP it gave me templates which included the following code:

use version; $VERSION = qv('0.0.1');
I know of no module named "version.pm", nor of any function named qv(). This code is throwing errors during the tests and build. Can anyone please clue me in on how this ought to be written, consistent with Perl Best Practices?

I'm guessing something like the following, but I don't really know. All clues appreciated.

# use version; our $VERSION = '0.0.1';
Thanks,
-- Hugh

if( $lal && $lol ) { $life++; }

Replies are listed 'Best First'.
Re: Is version a real module?
by ysth (Canon) on Dec 26, 2006 at 07:35 UTC
    Yes, version is a real module, available from CPAN and included with the perl distribution starting in version 5.9.0.

    If you are going to forgo using it, do not use a three-component version number; stick to a floating point number like '0.001'.

      So if I'm running version v5.8.4, what do I do with this? Is qv() a function of version.pm? Or is that a typo/bug? If I want to make my code compatible with older versions of perl, how would I adjust this code to run under my older version?

      Thanks
      -- Hugh

      if( $lal && $lol ) { $life++; }

        Is qv() a function of version.pm? Or is that a typo/bug?

        qv is a function exported by version.

        If I want to make my code compatible with older versions of perl

        It already is. Just install the module.

        The version module is available on CPAN, and should work with perl versions 5.005_04 or later. The Makefile.PL/META.yml created should list it as a prerequisite of your distribution. If you installed Module::Starter::PBP, you should have had a demonstration of how easy it is to install it as a prereq.

        Personally, I don't know that I'd consider it a best practice to use, especially with extended versions, but PBP is Damian's best practices, not mine.

Re: Is version a real module?
by jesuashok (Curate) on Dec 26, 2006 at 07:40 UTC