{
    "content": [
        {
            "type": "text",
            "text": "# SERIES (perldoc)\n\n## Sections\n\n- **Found in /usr/share/perl/5.34/pod/perlfaq4.pod**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "SERIES",
        "section": "-q",
        "mode": "perldoc",
        "summary": null,
        "synopsis": null,
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "Found in /usr/share/perl/5.34/pod/perlfaq4.pod",
                "lines": 37,
                "subsections": []
            }
        ],
        "sections": {
            "Found in /usr/share/perl/5.34/pod/perlfaq4.pod": {
                "content": "How do I perform an operation on a series of integers?\nTo call a function on each element in an array, and collect the results,\nuse:\n\nmy @results = map { myfunc($) } @array;\n\nFor example:\n\nmy @triple = map { 3 * $ } @single;\n\nTo call a function on each element of an array, but ignore the results:\n\nforeach my $iterator (@array) {\nsomefunc($iterator);\n}\n\nTo call a function on each integer in a (small) range, you can use:\n\nmy @results = map { somefunc($) } (5 .. 25);\n\nbut you should be aware that in this form, the \"..\" operator creates a\nlist of all integers in the range, which can take a lot of memory for\nlarge ranges. However, the problem does not occur when using \"..\" within\na \"for\" loop, because in that case the range operator is optimized to\n*iterate* over the range, without creating the entire list. So\n\nmy @results = ();\nfor my $i (5 .. 500005) {\npush(@results, somefunc($i));\n}\n\nor even\n\npush(@results, somefunc($)) for 5 .. 500005;\n\nwill not create an intermediate list of 500,000 integers.\n",
                "subsections": []
            }
        }
    }
}