{
    "mode": "perldoc",
    "parameter": "SERIES",
    "section": "-q",
    "url": "https://www.chedong.com/phpMan.php/perldoc/SERIES/json",
    "generated": "2026-07-05T23:46:06Z",
    "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": []
        }
    },
    "flags": [],
    "examples": [],
    "see_also": []
}