version::AlphaBeta - Use alphanumeric version objects
use version::AlphaBeta; $VERSION = version::AlphaBeta->new("v1.2b");
Derived class of version objects which permits use of specific alphanumeric version objects, patterned after the version strings used by many open source programs, like Mozilla.
The base version objects only permit a sequence of numeric values to be used, which is not how some software chooses to label their version strings. This module permits a specific sequence of alpha, beta, release candidate, release, and patch versions to be specified instead of strictly numeric versions. Sorted in increasing order:
Version Meaning 1.3a 1.3 alpha release 1.3b 1.3 beta release 1.3b2 1.3 second beta release 1.3rc 1.3 release candidate 1.3rc2 1.3 second release candidate 1.3 1.3 final release 1.3pl 1.3 first patch release 1.3pl2 1.3 second patch release
This module can be used as a basis for other subclasses of version objects. The global hash object %IB defines the acceptable non-numeric version parameters:
%IB = ( 'a' => -3, 'b' => -2, 'rc'=> -1, '' => 0, 'pl'=> 1 );
which, if present at all, must be located in the third sub-version.
This module overrides one of the base version object methods:
In order to safely compare version::AlphaBeta objects with non-objects or base version objects without using the overloaded comparison operators, for example in Module::Build, this module provides a numification operator. The floating point number returned may not be immediately obvious, but it it designed to sort in a consistent fashion as a number.
$v = version::AlphaBeta->new("1.0a1"); # 0.999997100 $v = version::AlphaBeta->new("1.0b1"); # 0.999998100 $v = version::AlphaBeta->new("1.0rc1"); # 0.999999100 $v = version::AlphaBeta->new("1.0"); # 1.000000 $v = version::AlphaBeta->new("1.0pl1"); # 1.000001100
Additionally, this module provides two additional logical methods, apart from those already provided by the base version class.
Replacing the base method by the same name, this will return true only if the version has an 'a' in the third position, i.e.
$VERSION = new version::AlphaBeta "1.3a1"; print $VERSION->is_alpha; # prints 1
A new method which supplements $obj->is_alpha:
$VERSION = new version::AlphaBeta "1.3b3"; print $VERSION->is_alpha; # prints 0 print $VERSION->is_beta; # prints 1
None by default.
John Peacock, <firstname.lastname@example.org>
Copyright 2003,2004,2005,2006 by John Peacock
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.