{
    "content": [
        {
            "type": "text",
            "text": "# POE::Filter::Block (perldoc)\n\n## NAME\n\nPOE::Filter::Block - translate data between streams and blocks\n\n## SYNOPSIS\n\n#!perl\nuse warnings;\nuse strict;\nuse POE::Filter::Block;\nmy $filter = POE::Filter::Block->new( BlockSize => 8 );\n# Prints three lines: abcdefgh, ijklmnop, qrstuvwx.\n# Bytes \"y\" and \"z\" remain in the buffer and await completion of the\n# next 8-byte block.\n$filter->getonestart([ \"abcdefghijklmnopqrstuvwxyz\" ]);\nwhile (1) {\nmy $block = $filter->getone();\nlast unless @$block;\nprint $block->[0], \"\\n\";\n}\n# Print one line: yz123456\n$filter->getonestart([ \"123456\" ]);\nwhile (1) {\nmy $block = $filter->getone();\nlast unless @$block;\nprint $block->[0], \"\\n\";\n}\n\n## DESCRIPTION\n\nPOE::Filter::Block translates data between serial streams and blocks. It can handle fixed-length\nand length-prepended blocks, and it may be extended to handle other block types.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **PUBLIC FILTER METHODS**\n- **SEE ALSO**\n- **BUGS**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "POE::Filter::Block",
        "section": "",
        "mode": "perldoc",
        "summary": "POE::Filter::Block - translate data between streams and blocks",
        "synopsis": "#!perl\nuse warnings;\nuse strict;\nuse POE::Filter::Block;\nmy $filter = POE::Filter::Block->new( BlockSize => 8 );\n# Prints three lines: abcdefgh, ijklmnop, qrstuvwx.\n# Bytes \"y\" and \"z\" remain in the buffer and await completion of the\n# next 8-byte block.\n$filter->getonestart([ \"abcdefghijklmnopqrstuvwxyz\" ]);\nwhile (1) {\nmy $block = $filter->getone();\nlast unless @$block;\nprint $block->[0], \"\\n\";\n}\n# Print one line: yz123456\n$filter->getonestart([ \"123456\" ]);\nwhile (1) {\nmy $block = $filter->getone();\nlast unless @$block;\nprint $block->[0], \"\\n\";\n}",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 28,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 53,
                "subsections": []
            },
            {
                "name": "PUBLIC FILTER METHODS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "BUGS",
                "lines": 7,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "POE::Filter::Block - translate data between streams and blocks\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "#!perl\n\nuse warnings;\nuse strict;\nuse POE::Filter::Block;\n\nmy $filter = POE::Filter::Block->new( BlockSize => 8 );\n\n# Prints three lines: abcdefgh, ijklmnop, qrstuvwx.\n# Bytes \"y\" and \"z\" remain in the buffer and await completion of the\n# next 8-byte block.\n\n$filter->getonestart([ \"abcdefghijklmnopqrstuvwxyz\" ]);\nwhile (1) {\nmy $block = $filter->getone();\nlast unless @$block;\nprint $block->[0], \"\\n\";\n}\n\n# Print one line: yz123456\n\n$filter->getonestart([ \"123456\" ]);\nwhile (1) {\nmy $block = $filter->getone();\nlast unless @$block;\nprint $block->[0], \"\\n\";\n}\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "POE::Filter::Block translates data between serial streams and blocks. It can handle fixed-length\nand length-prepended blocks, and it may be extended to handle other block types.\n\nFixed-length blocks are used when Block's constructor is called with a BlockSize value.\nOtherwise the Block filter uses length-prepended blocks.\n\nUsers who specify block sizes less than one deserve what they get.\n\nIn variable-length mode, a LengthCodec parameter may be specified. The LengthCodec value should\nbe a reference to a list of two functions: the length encoder, and the length decoder:\n\nLengthCodec => [ \\&encoder, \\&decoder ]\n\nThe encoder takes a reference to a buffer and prepends the buffer's length to it. The default\nencoder prepends the ASCII representation of the buffer's length and a chr(0) byte to separate\nthe length from the actual data:\n\nsub defaultencoder {\nmy $stuff = shift;\nsubstr($$stuff, 0, 0) = length($$stuff) . \"\\0\";\nreturn;\n}\n\nThe corresponding decoder returns the block length after removing it and the separator from the\nbuffer. It returns nothing if no length can be determined.\n\nsub defaultdecoder {\nmy $stuff = shift;\nunless ($$stuff =~ s/^(\\d+)\\0//s) {\nwarn length($1), \" strange bytes removed from stream\"\nif $$stuff =~ s/^(\\D+)//s;\nreturn;\n}\nreturn $1;\n}\n\nThis filter holds onto incomplete blocks until they are completed in a framing buffer. To\ncontrol memory usage, a maximum framing buffer size is imposed. This maximum size defaults to\n512 MB (512*1024*1024 octets). You may change this size limit with the \"MaxBuffer\" parameter.\n\nMaxBuffer => 1099511627776  # One terabyte!\n\nThe size of each individual block is also limited. By default, each block may be no more then 64\nMB. You may change this size limit with the \"MaxLength\" parameter.\n\nMaxLength => 10             # small blocks\n\nRemember that MaxBuffer needs to be larger then MaxLength. What's more, it needs to have room\nfor the length prefix.\n\nIf either the \"MaxLength\" or \"MaxBuffer\" constraint is exceeded, \"POE::Filter::Bock\" will throw\nan exception.\n",
                "subsections": []
            },
            "PUBLIC FILTER METHODS": {
                "content": "POE::Filter::Block has no additional public methods.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "Please see POE::Filter for documentation regarding the base interface.\n\nThe SEE ALSO section in POE contains a table of contents covering the entire POE distribution.\n",
                "subsections": []
            },
            "BUGS": {
                "content": "The put() method doesn't verify block sizes.\n\nAUTHORS & COPYRIGHTS\nThe Block filter was contributed by Dieter Pearcey, with changes by Rocco Caputo.\n\nPlease see POE for more information about authors and contributors.\n",
                "subsections": []
            }
        }
    }
}