{
    "content": [
        {
            "type": "text",
            "text": "# IO::String (perldoc)\n\n## NAME\n\nIO::String - Emulate file interface for in-core strings\n\n## SYNOPSIS\n\nuse IO::String;\n$io = IO::String->new;\n$io = IO::String->new($var);\ntie *IO, 'IO::String';\n# read data\n<$io>;\n$io->getline;\nread($io, $buf, 100);\n# write data\nprint $io \"string\\n\";\n$io->print(@data);\nsyswrite($io, $buf, 100);\nselect $io;\nprintf \"Some text %s\\n\", $str;\n# seek\n$pos = $io->getpos;\n$io->setpos(0);        # rewind\n$io->seek(-30, -1);\nseek($io, 0, 0);\n\n## DESCRIPTION\n\nThe \"IO::String\" module provides the \"IO::File\" interface for in-core strings. An \"IO::String\"\nobject can be attached to a string, and makes it possible to use the normal file operations for\nreading or writing data, as well as for seeking to various locations of the string. This is\nuseful when you want to use a library module that only provides an interface to file handles on\ndata that you have in a string variable.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **BUGS** (1 subsections)\n- **SEE ALSO**\n- **COPYRIGHT**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "IO::String",
        "section": "",
        "mode": "perldoc",
        "summary": "IO::String - Emulate file interface for in-core strings",
        "synopsis": "use IO::String;\n$io = IO::String->new;\n$io = IO::String->new($var);\ntie *IO, 'IO::String';\n# read data\n<$io>;\n$io->getline;\nread($io, $buf, 100);\n# write data\nprint $io \"string\\n\";\n$io->print(@data);\nsyswrite($io, $buf, 100);\nselect $io;\nprintf \"Some text %s\\n\", $str;\n# seek\n$pos = $io->getpos;\n$io->setpos(0);        # rewind\n$io->seek(-30, -1);\nseek($io, 0, 0);",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 24,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 50,
                "subsections": []
            },
            {
                "name": "BUGS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "seek",
                        "lines": 2
                    }
                ]
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "IO::String - Emulate file interface for in-core strings\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use IO::String;\n$io = IO::String->new;\n$io = IO::String->new($var);\ntie *IO, 'IO::String';\n\n# read data\n<$io>;\n$io->getline;\nread($io, $buf, 100);\n\n# write data\nprint $io \"string\\n\";\n$io->print(@data);\nsyswrite($io, $buf, 100);\n\nselect $io;\nprintf \"Some text %s\\n\", $str;\n\n# seek\n$pos = $io->getpos;\n$io->setpos(0);        # rewind\n$io->seek(-30, -1);\nseek($io, 0, 0);\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "The \"IO::String\" module provides the \"IO::File\" interface for in-core strings. An \"IO::String\"\nobject can be attached to a string, and makes it possible to use the normal file operations for\nreading or writing data, as well as for seeking to various locations of the string. This is\nuseful when you want to use a library module that only provides an interface to file handles on\ndata that you have in a string variable.\n\nNote that perl-5.8 and better has built-in support for \"in memory\" files, which are set up by\npassing a reference instead of a filename to the open() call. The reason for using this module\nis that it makes the code backwards compatible with older versions of Perl.\n\nThe \"IO::String\" module provides an interface compatible with \"IO::File\" as distributed with\nIO-1.20, but the following methods are not available: newfromfd, fdopen, formatwrite,\nformatpagenumber, formatlinesperpage, formatlinesleft, formatname, formattopname.\n\nThe following methods are specific to the \"IO::String\" class:\n\n$io = IO::String->new\n$io = IO::String->new( $string )\nThe constructor returns a newly-created \"IO::String\" object. It takes an optional argument,\nwhich is the string to read from or write into. If no $string argument is given, then an\ninternal buffer (initially empty) is allocated.\n\nThe \"IO::String\" object returned is tied to itself. This means that you can use most Perl\nI/O built-ins on it too: readline, <>, getc, print, printf, syswrite, sysread, close.\n\n$io->open\n$io->open( $string )\nAttaches an existing IO::String object to some other $string, or allocates a new internal\nbuffer (if no argument is given). The position is reset to 0.\n\n$io->stringref\nReturns a reference to the string that is attached to the \"IO::String\" object. Most useful\nwhen you let the \"IO::String\" create an internal buffer to write into.\n\n$io->pad\n$io->pad( $char )\nSpecifies the padding to use if the string is extended by either the seek() or truncate()\nmethods. It is a single character and defaults to \"\\0\".\n\n$io->pos\n$io->pos( $newpos )\nYet another interface for reading and setting the current read/write position within the\nstring (the normal getpos/setpos/tell/seek methods are also available). The pos() method\nalways returns the old position, and if you pass it an argument it sets the new position.\n\nThere is (deliberately) a difference between the setpos() and seek() methods in that seek()\nextends the string (with the specified padding) if you go to a location past the end,\nwhereas setpos() just snaps back to the end. If truncate() is used to extend the string,\nthen it works as seek().\n",
                "subsections": []
            },
            "BUGS": {
                "content": "In Perl versions < 5.6, the TIEHANDLE interface was incomplete. If you use such a Perl, then",
                "subsections": [
                    {
                        "name": "seek",
                        "content": "perltie for details.\n"
                    }
                ]
            },
            "SEE ALSO": {
                "content": "IO::File, IO::Stringy, \"open\" in perlfunc\n",
                "subsections": []
            },
            "COPYRIGHT": {
                "content": "Copyright 1998-2005 Gisle Aas.\n\nThis library is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself.\n",
                "subsections": []
            }
        }
    }
}