{
    "content": [
        {
            "type": "text",
            "text": "# Data::OptList (perldoc)\n\n## NAME\n\nData::OptList - parse and validate simple name/value option pairs\n\n## SYNOPSIS\n\nuse Data::OptList;\nmy $options = Data::OptList::mkopt([\nqw(key1 key2 key3 key4),\nkey5 => { ... },\nkey6 => [ ... ],\nkey7 => sub { ... },\nkey8 => { ... },\nkey8 => [ ... ],\n]);\n...is the same thing, more or less, as:\nmy $options = [\n[ key1 => undef,        ],\n[ key2 => undef,        ],\n[ key3 => undef,        ],\n[ key4 => undef,        ],\n[ key5 => { ... },      ],\n[ key6 => [ ... ],      ],\n[ key7 => sub { ... },  ],\n[ key8 => { ... },      ],\n[ key8 => [ ... ],      ],\n]);\n\n## DESCRIPTION\n\nHashes are great for storing named data, but if you want more than one entry for a name, you\nhave to use a list of pairs. Even then, this is really boring to write:\n\n## Sections\n\n- **NAME**\n- **VERSION**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **PERL VERSION SUPPORT**\n- **FUNCTIONS**\n- **EXPORTS**\n- **AUTHOR**\n- **CONTRIBUTOR**\n- **COPYRIGHT AND LICENSE**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Data::OptList",
        "section": "",
        "mode": "perldoc",
        "summary": "Data::OptList - parse and validate simple name/value option pairs",
        "synopsis": "use Data::OptList;\nmy $options = Data::OptList::mkopt([\nqw(key1 key2 key3 key4),\nkey5 => { ... },\nkey6 => [ ... ],\nkey7 => sub { ... },\nkey8 => { ... },\nkey8 => [ ... ],\n]);\n...is the same thing, more or less, as:\nmy $options = [\n[ key1 => undef,        ],\n[ key2 => undef,        ],\n[ key3 => undef,        ],\n[ key4 => undef,        ],\n[ key5 => { ... },      ],\n[ key6 => [ ... ],      ],\n[ key7 => sub { ... },  ],\n[ key8 => { ... },      ],\n[ key8 => [ ... ],      ],\n]);",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "VERSION",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 25,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 31,
                "subsections": []
            },
            {
                "name": "PERL VERSION SUPPORT",
                "lines": 7,
                "subsections": []
            },
            {
                "name": "FUNCTIONS",
                "lines": 52,
                "subsections": []
            },
            {
                "name": "EXPORTS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "CONTRIBUTOR",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "COPYRIGHT AND LICENSE",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Data::OptList - parse and validate simple name/value option pairs\n",
                "subsections": []
            },
            "VERSION": {
                "content": "version 0.112\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use Data::OptList;\n\nmy $options = Data::OptList::mkopt([\nqw(key1 key2 key3 key4),\nkey5 => { ... },\nkey6 => [ ... ],\nkey7 => sub { ... },\nkey8 => { ... },\nkey8 => [ ... ],\n]);\n\n...is the same thing, more or less, as:\n\nmy $options = [\n[ key1 => undef,        ],\n[ key2 => undef,        ],\n[ key3 => undef,        ],\n[ key4 => undef,        ],\n[ key5 => { ... },      ],\n[ key6 => [ ... ],      ],\n[ key7 => sub { ... },  ],\n[ key8 => { ... },      ],\n[ key8 => [ ... ],      ],\n]);\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Hashes are great for storing named data, but if you want more than one entry for a name, you\nhave to use a list of pairs. Even then, this is really boring to write:\n\n$values = [\nfoo => undef,\nbar => undef,\nbaz => undef,\nxyz => { ... },\n];\n\nJust look at all those undefs! Don't worry, we can get rid of those:\n\n$values = [\nmap { $ => undef } qw(foo bar baz),\nxyz => { ... },\n];\n\nAaaauuugh! We've saved a little typing, but now it requires thought to read, and thinking is\neven worse than typing... and it's got a bug! It looked right, didn't it? Well, the \"xyz => {\n... }\" gets consumed by the map, and we don't get the data we wanted.\n\nWith Data::OptList, you can do this instead:\n\n$values = Data::OptList::mkopt([\nqw(foo bar baz),\nxyz => { ... },\n]);\n\nThis works by assuming that any defined scalar is a name and any reference following a name is\nits value.\n",
                "subsections": []
            },
            "PERL VERSION SUPPORT": {
                "content": "This module has a long-term perl support period. That means it will not require a version of\nperl released fewer than five years ago.\n\nAlthough it may work on older versions of perl, no guarantee is made that the minimum required\nversion will not be increased. The version may be increased for any reason, and there is no\npromise that patches will be accepted to lower the minimum required perl.\n",
                "subsections": []
            },
            "FUNCTIONS": {
                "content": "mkopt\nmy $optlist = Data::OptList::mkopt($input, \\%arg);\n\nValid arguments are:\n\nmoniker        - a word used in errors to describe the opt list; encouraged\nrequireunique - if true, no name may appear more than once\nmustbe        - types to which opt list values are limited (described below)\nnametest      - a coderef used to test whether a value can be a name\n(described below, but you probably don't want this)\n\nThis produces an array of arrays; the inner arrays are name/value pairs. Values will be either\n\"undef\" or a reference.\n\nPositional parameters may be used for compatibility with the old \"mkopt\" interface:\n\nmy $optlist = Data::OptList::mkopt($input, $moniker, $requni, $mustbe);\n\nValid values for $input:\n\nundef    -> []\nhashref  -> [ [ key1 => value1 ] ... ] # non-ref values become undef\narrayref -> every name followed by a non-name becomes a pair: [ name => ref ]\nevery name followed by undef becomes a pair: [ name => undef ]\notherwise, it becomes [ name => undef ] like so:\n[ \"a\", \"b\", [ 1, 2 ] ] -> [ [ a => undef ], [ b => [ 1, 2 ] ] ]\n\nBy default, a *name* is any defined non-reference. The \"nametest\" parameter can be a code ref\nthat tests whether the argument passed it is a name or not. This should be used rarely.\nInteractions between \"requireunique\" and \"nametest\" are not yet particularly elegant, as\n\"requireunique\" just tests string equality. This may change.\n\nThe \"mustbe\" parameter is either a scalar or array of scalars; it defines what kind(s) of refs\nmay be values. If an invalid value is found, an exception is thrown. If no value is passed for\nthis argument, any reference is valid. If \"mustbe\" specifies that values must be CODE, HASH,\nARRAY, or SCALAR, then Params::Util is used to check whether the given value can provide that\ninterface. Otherwise, it checks that the given value is an object of the kind.\n\nIn other words:\n\n[ qw(SCALAR HASH Object::Known) ]\n\nMeans:\n\nSCALAR0($value) or HASH($value) or INSTANCE($value, 'Object::Known')\n\nmkopthash\nmy $opthash = Data::OptList::mkopthash($input, $moniker, $mustbe);\n\nGiven valid \"mkopt\" input, this routine returns a reference to a hash. It will throw an\nexception if any name has more than one value.\n",
                "subsections": []
            },
            "EXPORTS": {
                "content": "Both \"mkopt\" and \"mkopthash\" may be exported on request.\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "Ricardo Signes <rjbs@semiotic.systems>\n",
                "subsections": []
            },
            "CONTRIBUTOR": {
                "content": "Olivier Mengué <dolmen@cpan.org>\n",
                "subsections": []
            },
            "COPYRIGHT AND LICENSE": {
                "content": "This software is copyright (c) 2006 by Ricardo Signes.\n\nThis is free software; you can redistribute it and/or modify it under the same terms as the Perl\n5 programming language system itself.\n",
                "subsections": []
            }
        }
    }
}