{
    "mode": "perldoc",
    "parameter": "Params::Classify",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Params%3A%3AClassify/json",
    "generated": "2026-06-12T16:25:26Z",
    "synopsis": "use Params::Classify qw(\nscalarclass\nisundef checkundef\nisstring checkstring\nisnumber checknumber\nisglob checkglob\nisregexp checkregexp\nisref checkref reftype\nisblessed checkblessed blessedclass\nisstrictlyblessed checkstrictlyblessed\nisable checkable);\n$c = scalarclass($arg);\nif(isundef($arg)) {\ncheckundef($arg);\nif(isstring($arg)) {\ncheckstring($arg);\nif(isnumber($arg)) {\nchecknumber($arg);\nif(isglob($arg)) {\ncheckglob($arg);\nif(isregexp($arg)) {\ncheckregexp($arg);\nif(isref($arg)) {\ncheckref($arg);\n$t = reftype($arg);\nif(isref($arg, \"HASH\")) {\ncheckref($arg, \"HASH\");\nif(isblessed($arg)) {\ncheckblessed($arg);\nif(isblessed($arg, \"IO::Handle\")) {\ncheckblessed($arg, \"IO::Handle\");\n$c = blessedclass($arg);\nif(isstrictlyblessed($arg, \"IO::Pipe::End\")) {\ncheckstrictlyblessed($arg, \"IO::Pipe::End\");\nif(isable($arg, [\"print\", \"flush\"])) {\ncheckable($arg, [\"print\", \"flush\"]);",
    "sections": {
        "NAME": {
            "content": "Params::Classify - argument type classification\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Params::Classify qw(\nscalarclass\nisundef checkundef\nisstring checkstring\nisnumber checknumber\nisglob checkglob\nisregexp checkregexp\nisref checkref reftype\nisblessed checkblessed blessedclass\nisstrictlyblessed checkstrictlyblessed\nisable checkable);\n\n$c = scalarclass($arg);\n\nif(isundef($arg)) {\ncheckundef($arg);\n\nif(isstring($arg)) {\ncheckstring($arg);\nif(isnumber($arg)) {\nchecknumber($arg);\n\nif(isglob($arg)) {\ncheckglob($arg);\nif(isregexp($arg)) {\ncheckregexp($arg);\n\nif(isref($arg)) {\ncheckref($arg);\n$t = reftype($arg);\nif(isref($arg, \"HASH\")) {\ncheckref($arg, \"HASH\");\n\nif(isblessed($arg)) {\ncheckblessed($arg);\nif(isblessed($arg, \"IO::Handle\")) {\ncheckblessed($arg, \"IO::Handle\");\n$c = blessedclass($arg);\nif(isstrictlyblessed($arg, \"IO::Pipe::End\")) {\ncheckstrictlyblessed($arg, \"IO::Pipe::End\");\nif(isable($arg, [\"print\", \"flush\"])) {\ncheckable($arg, [\"print\", \"flush\"]);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This module provides various type-testing functions. These are intended for functions that,\nunlike most Perl code, care what type of data they are operating on. For example, some functions\nwish to behave differently depending on the type of their arguments (like overloaded functions\nin C++).\n\nThere are two flavours of function in this module. Functions of the first flavour only provide\ntype classification, to allow code to discriminate between argument types. Functions of the\nsecond flavour package up the most common type of type discrimination: checking that an argument\nis of an expected type. The functions come in matched pairs, of the two flavours, and so the\ntype enforcement functions handle only the simplest requirements for arguments of the types\nhandled by the classification functions. Enforcement of more complex types may, of course, be\nbuilt using the classification functions, or it may be more convenient to use a module designed\nfor the more complex job, such as Params::Validate.\n\nThis module is implemented in XS, with a pure Perl backup version for systems that can't handle\nXS.\n",
            "subsections": []
        },
        "TYPE CLASSIFICATION": {
            "content": "This module divides up scalar values into the following classes:\n\n*   undef\n\n*   string (defined ordinary scalar)\n\n*   typeglob (yes, typeglobs fit into scalar variables)\n\n*   regexp (first-class regular expression objects in Perl 5.11 onwards)\n\n*   reference to unblessed object (further classified by physical data type of the referenced\nobject)\n\n*   reference to blessed object (further classified by class blessed into)\n\nThese classes are mutually exclusive and should be exhaustive. This classification has been\nchosen as the most useful when one wishes to discriminate between types of scalar. Other\nclassifications are possible. (For example, the two reference classes are distinguished by a\nfeature of the referenced object; Perl does not internally treat this as a feature of the\nreference.)\n",
            "subsections": []
        },
        "FUNCTIONS": {
            "content": "Each of these functions takes one scalar argument (*ARG*) to be tested, possibly with other\narguments specifying details of the test. Any scalar value is acceptable for the argument to be\ntested. Each \"is\" function returns a simple truth value result, which is true iff *ARG* is of\nthe type being checked for. Each \"check\" function will return normally if the argument is of\nthe type being checked for, or will \"die\" if it is not.\n",
            "subsections": [
                {
                    "name": "Classification",
                    "content": ""
                },
                {
                    "name": "scalar_class",
                    "content": "Determines which of the five classes described above *ARG* falls into. Returns \"UNDEF\",\n\"STRING\", \"GLOB\", \"REGEXP\", \"REF\", or \"BLESSED\" accordingly.\n"
                },
                {
                    "name": "The Undefined Value",
                    "content": ""
                },
                {
                    "name": "is_undef",
                    "content": ""
                },
                {
                    "name": "check_undef",
                    "content": "Check whether *ARG* is \"undef\". \"isundef(ARG)\" is precisely equivalent to \"!defined(ARG)\",\nand is included for completeness.\n"
                },
                {
                    "name": "Strings",
                    "content": ""
                },
                {
                    "name": "is_string",
                    "content": ""
                },
                {
                    "name": "check_string",
                    "content": "Check whether *ARG* is defined and is an ordinary scalar value (not a reference, typeglob,\nor regexp). This is what one usually thinks of as a string in Perl. In fact, any scalar\n(including \"undef\" and references) can be coerced to a string, but if you're trying to\nclassify a scalar then you don't want to do that.\n"
                },
                {
                    "name": "is_number",
                    "content": ""
                },
                {
                    "name": "check_number",
                    "content": "Check whether *ARG* is defined and an ordinary scalar (i.e., satisfies \"isstring\" above)\nand is an acceptable number to Perl. This is what one usually thinks of as a number.\n\nNote that simple (\"isstring\"-satisfying) scalars may have independent numeric and string\nvalues, despite the usual pretence that they have only one value. Such a scalar is deemed to\nbe a number if *either* it already has a numeric value (e.g., was generated by a numeric\nliteral or an arithmetic computation) *or* its string value has acceptable syntax for a\nnumber (so it can be converted). Where a scalar has separate numeric and string values (see\n\"dualvar\" in Scalar::Util), it is possible for it to have an acceptable numeric value while\nits string value does *not* have acceptable numeric syntax. Be careful to use such a value\nonly in a numeric context, if you are using it as a number. \"scalarnumpart\" in\nScalar::Number extracts the numeric part of a scalar as an ordinary number. (\"0+ARG\"\nsuffices for that unless you need to preserve floating point signed zeroes.)\n\nA number may be either a native integer or a native floating point value, and there are\nseveral subtypes of floating point value. For classification, and other handling of numbers\nin scalars, see Scalar::Number. For details of the two numeric data types, see Data::Integer\nand Data::Float.\n\nThis function differs from \"lookslikenumber\" (see \"lookslikenumber\" in Scalar::Util;\nalso \"lookslikenumber\" in perlapi for a lower-level description) in excluding \"undef\",\ntypeglobs, and references. Why \"lookslikenumber\" returns true for \"undef\" or typeglobs is\nanybody's guess. References, if treated as numbers, evaluate to the address in memory that\nthey reference; this is useful for comparing references for equality, but it is not\notherwise useful to treat references as numbers. Blessed references may have overloaded\nnumeric operators, but if so then they don't necessarily behave like ordinary numbers.\n\"lookslikenumber\" is also confused by dualvars: it looks at the string portion of the\nscalar.\n"
                },
                {
                    "name": "Typeglobs",
                    "content": ""
                },
                {
                    "name": "is_glob",
                    "content": ""
                },
                {
                    "name": "check_glob",
                    "content": "Check whether *ARG* is a typeglob.\n"
                },
                {
                    "name": "Regexps",
                    "content": ""
                },
                {
                    "name": "is_regexp",
                    "content": ""
                },
                {
                    "name": "check_regexp",
                    "content": "Check whether *ARG* is a regexp object.\n"
                },
                {
                    "name": "References to Unblessed Objects",
                    "content": ""
                },
                {
                    "name": "is_ref",
                    "content": ""
                },
                {
                    "name": "check_ref",
                    "content": "Check whether *ARG* is a reference to an unblessed object. If it is, then the referenced\ndata type can be determined using \"reftype\" (see below), which will return a string such as\n\"HASH\" or \"SCALAR\".\n"
                },
                {
                    "name": "ref_type",
                    "content": "Returns \"undef\" if *ARG* is not a reference to an unblessed object. Otherwise, determines\nwhat type of object is referenced. Returns \"SCALAR\", \"ARRAY\", \"HASH\", \"CODE\", \"FORMAT\", or\n\"IO\" accordingly.\n\nNote that, unlike \"ref\", this does not distinguish between different types of referenced\nscalar. A reference to a string and a reference to a reference will both return \"SCALAR\".\nConsequently, what \"reftype\" returns for a particular reference will not change due to\nchanges in the value of the referent, except for the referent being blessed.\n"
                },
                {
                    "name": "is_ref",
                    "content": ""
                },
                {
                    "name": "check_ref",
                    "content": "Check whether *ARG* is a reference to an unblessed object of type *TYPE*, as determined by\n\"reftype\". *TYPE* must be a string. Possible *TYPE*s are \"SCALAR\", \"ARRAY\", \"HASH\", \"CODE\",\n\"FORMAT\", and \"IO\".\n"
                },
                {
                    "name": "References to Blessed Objects",
                    "content": ""
                },
                {
                    "name": "is_blessed",
                    "content": ""
                },
                {
                    "name": "check_blessed",
                    "content": "Check whether *ARG* is a reference to a blessed object. If it is, then the class into which\nthe object was blessed can be determined using \"blessedclass\".\n"
                },
                {
                    "name": "is_blessed",
                    "content": ""
                },
                {
                    "name": "check_blessed",
                    "content": "Check whether *ARG* is a reference to a blessed object that claims to be an instance of\n*CLASS* (via its \"isa\" method; see \"isa\" in perlobj). *CLASS* must be a string, naming a\nPerl class.\n"
                },
                {
                    "name": "blessed_class",
                    "content": "Returns \"undef\" if *ARG* is not a reference to a blessed object. Otherwise, returns the\nclass into which the object is blessed.\n\n\"ref\" (see \"ref\" in perlfunc) gives the same result on references to blessed objects, but\ndifferent results on other types of value. \"blessedclass\" is actually identical to\n\"blessed\" in Scalar::Util.\n"
                },
                {
                    "name": "is_strictly_blessed",
                    "content": ""
                },
                {
                    "name": "check_strictly_blessed",
                    "content": "Check whether *ARG* is a reference to a blessed object, identically to \"isblessed\". This\nexists only for symmetry; the useful form of \"isstrictlyblessed\" appears below.\n"
                },
                {
                    "name": "is_strictly_blessed",
                    "content": ""
                },
                {
                    "name": "check_strictly_blessed",
                    "content": "Check whether *ARG* is a reference to an object blessed into *CLASS* exactly. *CLASS* must\nbe a string, naming a Perl class. Because this excludes subclasses, this is rarely what one\nwants, but there are some specialised occasions where it is useful.\n"
                },
                {
                    "name": "is_able",
                    "content": ""
                },
                {
                    "name": "check_able",
                    "content": "Check whether *ARG* is a reference to a blessed object, identically to \"isblessed\". This\nexists only for symmetry; the useful form of \"isable\" appears below.\n"
                },
                {
                    "name": "is_able",
                    "content": ""
                },
                {
                    "name": "check_able",
                    "content": "Check whether *ARG* is a reference to a blessed object that claims to implement the methods\nspecified by *METHODS* (via its \"can\" method; see \"can\" in perlobj). *METHODS* must be\neither a single method name or a reference to an array of method names. Each method name is\na string. This interface check is often more appropriate than a direct ancestry check (such\nas \"isblessed\" performs).\n"
                }
            ]
        },
        "BUGS": {
            "content": "Probably ought to handle something like Params::Validate's scalar type specification system,\nwhich makes much the same distinctions.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Data::Float, Data::Integer, Params::Validate, Scalar::Number, Scalar::Util\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Andrew Main (Zefram) <zefram@fysh.org>\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright (C) 2004, 2006, 2007, 2009, 2010, 2017 Andrew Main (Zefram) <zefram@fysh.org>\n\nCopyright (C) 2009, 2010 PhotoBox Ltd\n",
            "subsections": []
        },
        "LICENSE": {
            "content": "This module is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself.\n",
            "subsections": []
        }
    },
    "summary": "Params::Classify - argument type classification",
    "flags": [],
    "examples": [],
    "see_also": []
}