{
    "content": [
        {
            "type": "text",
            "text": "# POE::Filter::Map (perldoc)\n\n## NAME\n\nPOE::Filter::Map - transform input and/or output within a filter stack\n\n## SYNOPSIS\n\n#!perl\nuse POE qw(\nWheel::FollowTail\nFilter::Line Filter::Map Filter::Stackable\n);\nPOE::Session->create(\ninlinestates => {\nstart => sub {\nmy $parseinputaslines = POE::Filter::Line->new();\nmy $redactsomelines = POE::Filter::Map->new(\nCode => sub {\nmy $input = shift;\n$input = \"[REDACTED]\" unless $input =~ /sudo\\[\\d+\\]/i;\nreturn $input;\n},\n);\nmy $filterstack = POE::Filter::Stackable->new(\nFilters => [\n$parseinputaslines, # first on get, last on put\n$redactsomelines, # first on put, last on get\n]\n);\n$[HEAP]{tailor} = POE::Wheel::FollowTail->new(\nFilename => \"/var/log/system.log\",\nInputEvent => \"gotlogline\",\nFilter => $filterstack,\n);\n},\ngotlogline => sub {\nprint \"Log: $[ARG0]\\n\";\n}\n}\n);\nPOE::Kernel->run();\nexit;\n\n## DESCRIPTION\n\nPOE::Filter::Map transforms data inside the filter stack. It may be used to transform input,\noutput, or both depending on how it is constructed. This filter is named and modeled after\nPerl's built-in map() function.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **PUBLIC FILTER METHODS** (2 subsections)\n- **SEE ALSO**\n- **BUGS**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "POE::Filter::Map",
        "section": "",
        "mode": "perldoc",
        "summary": "POE::Filter::Map - transform input and/or output within a filter stack",
        "synopsis": "#!perl\nuse POE qw(\nWheel::FollowTail\nFilter::Line Filter::Map Filter::Stackable\n);\nPOE::Session->create(\ninlinestates => {\nstart => sub {\nmy $parseinputaslines = POE::Filter::Line->new();\nmy $redactsomelines = POE::Filter::Map->new(\nCode => sub {\nmy $input = shift;\n$input = \"[REDACTED]\" unless $input =~ /sudo\\[\\d+\\]/i;\nreturn $input;\n},\n);\nmy $filterstack = POE::Filter::Stackable->new(\nFilters => [\n$parseinputaslines, # first on get, last on put\n$redactsomelines, # first on put, last on get\n]\n);\n$[HEAP]{tailor} = POE::Wheel::FollowTail->new(\nFilename => \"/var/log/system.log\",\nInputEvent => \"gotlogline\",\nFilter => $filterstack,\n);\n},\ngotlogline => sub {\nprint \"Log: $[ARG0]\\n\";\n}\n}\n);\nPOE::Kernel->run();\nexit;",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 42,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "PUBLIC FILTER METHODS",
                "lines": 3,
                "subsections": [
                    {
                        "name": "new",
                        "lines": 36
                    },
                    {
                        "name": "modify",
                        "lines": 7
                    }
                ]
            },
            {
                "name": "SEE ALSO",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "BUGS",
                "lines": 7,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "POE::Filter::Map - transform input and/or output within a filter stack\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "#!perl\n\nuse POE qw(\nWheel::FollowTail\nFilter::Line Filter::Map Filter::Stackable\n);\n\nPOE::Session->create(\ninlinestates => {\nstart => sub {\nmy $parseinputaslines = POE::Filter::Line->new();\n\nmy $redactsomelines = POE::Filter::Map->new(\nCode => sub {\nmy $input = shift;\n$input = \"[REDACTED]\" unless $input =~ /sudo\\[\\d+\\]/i;\nreturn $input;\n},\n);\n\nmy $filterstack = POE::Filter::Stackable->new(\nFilters => [\n$parseinputaslines, # first on get, last on put\n$redactsomelines, # first on put, last on get\n]\n);\n\n$[HEAP]{tailor} = POE::Wheel::FollowTail->new(\nFilename => \"/var/log/system.log\",\nInputEvent => \"gotlogline\",\nFilter => $filterstack,\n);\n},\ngotlogline => sub {\nprint \"Log: $[ARG0]\\n\";\n}\n}\n);\n\nPOE::Kernel->run();\nexit;\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "POE::Filter::Map transforms data inside the filter stack. It may be used to transform input,\noutput, or both depending on how it is constructed. This filter is named and modeled after\nPerl's built-in map() function.\n\nPOE::Filter::Map is designed to be combined with other filters through POE::Filter::Stackable.\nIn the \"SYNOPSIS\" example, a filter stack is created to parse logs as lines and redact all\nentries that don't pertain to a sudo process.\n",
                "subsections": []
            },
            "PUBLIC FILTER METHODS": {
                "content": "In addition to the usual POE::Filter methods, POE::Filter::Map also supports the following.\n\nnew",
                "subsections": [
                    {
                        "name": "new",
                        "content": "parameter, or both a Put and a Get parameter. The values for Code, Put and Get are code\nreferences that, when invoked, return transformed versions of their sole parameters. A Code\nfunction will be used for both input and output, while Get and Put functions allow input and\noutput to be filtered in different ways.\n\n# Decrypt rot13.\nsub decryptrot13 {\nmy $encrypted = shift;\n$encrypted =~ tr[a-zA-Z][n-za-mN-ZA-M];\nreturn $encrypted;\n}\n\n# Encrypt rot13.\nsub encryptrot13 {\nmy $plaintext = shift;\n$plaintext =~ tr[a-zA-Z][n-za-mN-ZA-M];\nreturn $plaintext;\n}\n\n# Decrypt rot13 on input, and encrypt it on output.\nmy $rot13transcrypter = POE::Filter::Map->new(\nGet => \\&decryptrot13,\nPut => \\&encryptrot13,\n);\n\nRot13 is symmetric, so the above example can be simplified to use a single Code function.\n\nmy $rot13transcrypter = POE::Filter::Map->new(\nCode => sub {\nlocal $ = shift;\ntr[a-zA-Z][n-za-mN-ZA-M];\nreturn $;\n}\n);\n\nmodify"
                    },
                    {
                        "name": "modify",
                        "content": "parameters as new(), and it replaces the existing transforms with new ones.\n\n# Switch to \"reverse\" encryption for testing.\n$rot13transcrypter->modify(\nCode => sub { return scalar reverse shift }\n);\n"
                    }
                ]
            },
            "SEE ALSO": {
                "content": "POE::Filter for more information about filters in general.\n\nPOE::Filter::Stackable for more details on stacking filters.\n",
                "subsections": []
            },
            "BUGS": {
                "content": "None known.\n\nAUTHORS & COPYRIGHTS\nThe Map filter was contributed by Dieter Pearcey. Documentation is provided by Rocco Caputo.\n\nPlease see the POE manpage for more information about authors and contributors.\n",
                "subsections": []
            }
        }
    }
}