{
    "mode": "perldoc",
    "parameter": "version",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/version/json",
    "generated": "2026-07-05T13:04:44Z",
    "synopsis": "# Parsing version strings (decimal or dotted-decimal)\nuse version 0.77; # get latest bug-fixes and API\n$ver = version->parse($string)\n# Declaring a dotted-decimal $VERSION (keep on one line!)\nuse version; our $VERSION = version->declare(\"v1.2.3\"); # formal\nuse version; our $VERSION = qv(\"v1.2.3\");               # deprecated\nuse version; our $VERSION = qv(\"v1.23\");               # deprecated\n# Declaring an old-style decimal $VERSION (use quotes!)\nour $VERSION = \"1.0203\";                                # recommended\nuse version; our $VERSION = version->parse(\"1.0203\");   # formal\nuse version; our $VERSION = version->parse(\"1.0203\");  # alpha\n# Comparing mixed version styles (decimals, dotted-decimals, objects)\nif ( version->parse($v1) == version->parse($v2) ) {\n# do stuff\n}\n# Sorting mixed version styles\n@ordered = sort { version->parse($a) <=> version->parse($b) } @list;",
    "sections": {
        "NAME": {
            "content": "version - Perl extension for Version Objects\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "# Parsing version strings (decimal or dotted-decimal)\n\nuse version 0.77; # get latest bug-fixes and API\n$ver = version->parse($string)\n\n# Declaring a dotted-decimal $VERSION (keep on one line!)\n\nuse version; our $VERSION = version->declare(\"v1.2.3\"); # formal\nuse version; our $VERSION = qv(\"v1.2.3\");               # deprecated\nuse version; our $VERSION = qv(\"v1.23\");               # deprecated\n\n# Declaring an old-style decimal $VERSION (use quotes!)\n\nour $VERSION = \"1.0203\";                                # recommended\nuse version; our $VERSION = version->parse(\"1.0203\");   # formal\nuse version; our $VERSION = version->parse(\"1.0203\");  # alpha\n\n# Comparing mixed version styles (decimals, dotted-decimals, objects)\n\nif ( version->parse($v1) == version->parse($v2) ) {\n# do stuff\n}\n\n# Sorting mixed version styles\n\n@ordered = sort { version->parse($a) <=> version->parse($b) } @list;\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Version objects were added to Perl in 5.10. This module implements version objects for older\nversion of Perl and provides the version object API for all versions of Perl. All previous\nreleases before 0.74 are deprecated and should not be used due to incompatible API changes.\nVersion 0.77 introduces the new 'parse' and 'declare' methods to standardize usage. You are\nstrongly urged to set 0.77 as a minimum in your code, e.g.\n\nuse version 0.77; # even for Perl v.5.10.0\n",
            "subsections": []
        },
        "TYPES OF VERSION OBJECTS": {
            "content": "There are two different types of version objects, corresponding to the two different styles of\nversions in use:\n\nDecimal Versions\nThe classic floating-point number $VERSION. The advantage to this style is that you don't need\nto do anything special, just type a number into your source file. Quoting is recommended, as\nit ensures that trailing zeroes (\"1.50\") are preserved in any warnings or other output.\n\nDotted Decimal Versions\nThe more modern form of version assignment, with 3 (or potentially more) integers separated by\ndecimal points (e.g. v1.2.3). This is the form that Perl itself has used since 5.6.0 was\nreleased. The leading 'v' is now strongly recommended for clarity, and will throw a warning in\na future release if omitted. A leading 'v' character is required to pass the \"isstrict()\"\ntest.\n",
            "subsections": []
        },
        "DECLARING VERSIONS": {
            "content": "If you have a module that uses a decimal $VERSION (floating point), and you do not intend to\never change that, this module is not for you. There is nothing that version.pm gains you over a\nsimple $VERSION assignment:\n\nour $VERSION = \"1.02\";\n\nSince Perl v5.10.0 includes the version.pm comparison logic anyways, you don't need to do\nanything at all.\n",
            "subsections": [
                {
                    "name": "How to convert a module from decimal to dotted-decimal",
                    "content": "If you have used a decimal $VERSION in the past and wish to switch to a dotted-decimal $VERSION,\nthen you need to make a one-time conversion to the new format.\n\nImportant Note: you must ensure that your new $VERSION is numerically greater than your current\ndecimal $VERSION; this is not always obvious. First, convert your old decimal version (e.g.\n1.02) to a normalized dotted-decimal form:\n\n$ perl -Mversion -e 'print version->parse(\"1.02\")->normal'\nv1.20.0\n\nThen increment any of the dotted-decimal components (v1.20.1 or v1.21.0).\n\nHow to \"declare()\" a dotted-decimal version\nuse version; our $VERSION = version->declare(\"v1.2.3\");\n\nThe \"declare()\" method always creates dotted-decimal version objects. When used in a module, you\nmust put it on the same line as \"use version\" to ensure that $VERSION is read correctly by PAUSE\nand installer tools. You should also add 'version' to the 'configurerequires' section of your\nmodule metadata file. See instructions in ExtUtils::MakeMaker or Module::Build for details.\n\nImportant Note: Even if you pass in what looks like a decimal number (\"1.2\"), a dotted-decimal\nwill be created (\"v1.200.0\"). To avoid confusion or unintentional errors on older Perls, follow\nthese guidelines:\n\n* Always use a dotted-decimal with (at least) three components\n\n* Always use a leading-v\n\n* Always quote the version\n\nIf you really insist on using version.pm with an ordinary decimal version, use \"parse()\" instead\nof declare. See the \"PARSING AND COMPARING VERSIONS\" for details.\n\nSee also version::Internals for more on version number conversion, quoting, calculated version\nnumbers and declaring developer or \"alpha\" version numbers.\n"
                }
            ]
        },
        "PARSING AND COMPARING VERSIONS": {
            "content": "If you need to compare version numbers, but can't be sure whether they are expressed as numbers,\nstrings, v-strings or version objects, then you should use version.pm to parse them all into\nobjects for comparison.\n\nHow to \"parse()\" a version\nThe \"parse()\" method takes in anything that might be a version and returns a corresponding\nversion object, doing any necessary conversion along the way.\n\n* Dotted-decimal: bare v-strings (v1.2.3) and strings with more than one decimal point and a\nleading 'v' (\"v1.2.3\"); NOTE you can technically use a v-string or strings with a leading-v\nand only one decimal point (v1.2 or \"v1.2\"), but you will confuse both yourself and others.\n\n* Decimal: regular decimal numbers (literal or in a string)\n\nSome examples:\n\n$variable   version->parse($variable)\n---------   -------------------------\n1.23        v1.230.0\n\"1.23\"      v1.230.0\nv1.23       v1.23.0\n\"v1.23\"     v1.23.0\n\"1.2.3\"     v1.2.3\n\"v1.2.3\"    v1.2.3\n\nSee version::Internals for more on version number conversion.\n",
            "subsections": [
                {
                    "name": "How to check for a legal version string",
                    "content": "If you do not want to actually create a full blown version object, but would still like to\nverify that a given string meets the criteria to be parsed as a version, there are two helper\nfunctions that can be employed directly:\n\n\"islax()\"\nThe lax criteria corresponds to what is currently allowed by the version parser. All of the\nfollowing formats are acceptable for dotted-decimal formats strings:\n\nv1.2\n1.2345.6\nv1.234\n1.2345\n1.234501\n\n\"isstrict()\"\nIf you want to limit yourself to a much more narrow definition of what a version string\nconstitutes, \"isstrict()\" is limited to version strings like the following list:\n\nv1.234.5\n2.3456\n\nSee version::Internals for details of the regular expressions that define the legal version\nstring forms, as well as how to use those regular expressions in your own code if \"islax()\" and\n\"isstrict()\" are not sufficient for your needs.\n"
                },
                {
                    "name": "How to compare version objects",
                    "content": "Version objects overload the \"cmp\" and \"<=>\" operators. Perl automatically generates all of the\nother comparison operators based on those two so all the normal logical comparisons will work.\n\nif ( version->parse($v1) == version->parse($v2) ) {\n# do stuff\n}\n\nIf a version object is compared against a non-version object, the non-object term will be\nconverted to a version object using \"parse()\". This may give surprising results:\n\n$v1 = version->parse(\"v0.95.0\");\n$bool = $v1 < 0.94; # TRUE since 0.94 is v0.940.0\n\nAlways comparing to a version object will help avoid surprises:\n\n$bool = $v1 < version->parse(\"v0.94.0\"); # FALSE\n\nNote that \"alpha\" version objects (where the version string contains a trailing underscore\nsegment) compare as less than the equivalent version without an underscore:\n\n$bool = version->parse(\"1.2345\") < version->parse(\"1.2345\"); # TRUE\n\nSee version::Internals for more details on \"alpha\" versions.\n"
                }
            ]
        },
        "OBJECT METHODS": {
            "content": "isalpha()\nTrue if and only if the version object was created with a underscore, e.g.\n\nversion->parse('1.00203')->isalpha;  # TRUE\nversion->declare('1.2.34')->isalpha; # TRUE\n\nisqv()\nTrue only if the version object is a dotted-decimal version, e.g.\n\nversion->parse('v1.2.0')->isqv;       # TRUE\nversion->declare('v1.2')->isqv;       # TRUE\nqv('1.2')->isqv;                      # TRUE\nversion->parse('1.2')->isqv;          # FALSE\n\nnormal()\nReturns a string with a standard 'normalized' dotted-decimal form with a leading-v and at least\n3 components.\n\nversion->declare('v1.2')->normal;  # v1.2.0\nversion->parse('1.2')->normal;     # v1.200.0\n\nnumify()\nReturns a value representing the object in a pure decimal.\n\nversion->declare('v1.2')->numify;  # 1.002000\nversion->parse('1.2')->numify;     # 1.200\n\nstringify()\nReturns a string that is as close to the original representation as possible. If the original\nrepresentation was a numeric literal, it will be returned the way perl would normally represent\nit in a string. This method is used whenever a version object is interpolated into a string.\n\nversion->declare('v1.2')->stringify;    # v1.2\nversion->parse('1.200')->stringify;     # 1.2\nversion->parse(1.0230)->stringify;     # 1.023\n",
            "subsections": []
        },
        "EXPORTED FUNCTIONS": {
            "content": "qv()\nThis function is no longer recommended for use, but is maintained for compatibility with\nexisting code. If you do not want to have it exported to your namespace, use this form:\n\nuse version 0.77 ();\n\nislax()\n(Not exported by default)\n\nThis function takes a scalar argument and returns a boolean value indicating whether the\nargument meets the \"lax\" rules for a version number. Leading and trailing spaces are not\nallowed.\n\nisstrict()\n(Not exported by default)\n\nThis function takes a scalar argument and returns a boolean value indicating whether the\nargument meets the \"strict\" rules for a version number. Leading and trailing spaces are not\nallowed.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "John Peacock <jpeacock@cpan.org>\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "version::Internals.\n\nperl.\n",
            "subsections": []
        }
    },
    "summary": "version - Perl extension for Version Objects",
    "flags": [],
    "examples": [],
    "see_also": []
}