NAME

Version::Semantic - Tiny SemVer based class implementation

SYNOPSIS

use Version::Semantic ();

my $v_unstable = Version::Semantic->parse( '1.0.0-alpha' );
my $v_testing  = Version::Semantic->parse( '1.0.0-beta' );
my $v_stable   = Version::Semantic->parse( 'v1.0.0' );

if ( $v_unstable < $v_testing and $v_testing < $v_stable ) {
  ...
}

DESCRIPTION

This class defines immutable version objects that support the Semantic Versioning Specification (SemVer).

The class has a parse( $version ) factory method (a class method) to create objects from their semantic version strings. The method accepts semantic version strings that have a v prefix (Is "v1.2.3" a semantic version?).

Each object has the mandatory attributes major, minor, and patch. Optional object attributes are pre_release and build. has_pre_release() and has_build_() predicate methods exist too.

The version_core() object method returns the semantic version string of an object with the v prefix (if originally set) but without the pre-release and the build extensions.

The to_string() object method returns the semantic version string of an object including the v prefix (if originally set). The method is used to overload the stringification "" operator.

The compare_to() object method implements the SemVer precedence rules. This method is used to overload the numeric comparison <=> operator. This allows you to compare version objects.

SEE ALSO

AUTHOR

Sven Willenbuecher <sven.willenbuecher@gmx.de>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Sven Willenbuecher.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.