{
    "content": [
        {
            "type": "text",
            "text": "# IO::Zlib (perldoc)\n\n## NAME\n\nIO::Zlib - IO:: style interface to Compress::Zlib\n\n## SYNOPSIS\n\nWith any version of Perl 5 you can use the basic OO interface:\nuse IO::Zlib;\n$fh = new IO::Zlib;\nif ($fh->open(\"file.gz\", \"rb\")) {\nprint <$fh>;\n$fh->close;\n}\n$fh = IO::Zlib->new(\"file.gz\", \"wb9\");\nif (defined $fh) {\nprint $fh \"bar\\n\";\n$fh->close;\n}\n$fh = IO::Zlib->new(\"file.gz\", \"rb\");\nif (defined $fh) {\nprint <$fh>;\nundef $fh;       # automatically closes the file\n}\nWith Perl 5.004 you can also use the TIEHANDLE interface to access compressed files just like\nordinary files:\nuse IO::Zlib;\ntie *FILE, 'IO::Zlib', \"file.gz\", \"wb\";\nprint FILE \"line 1\\nline2\\n\";\ntie *FILE, 'IO::Zlib', \"file.gz\", \"rb\";\nwhile (<FILE>) { print \"LINE: \", $ };\n\n## DESCRIPTION\n\n\"IO::Zlib\" provides an IO:: style interface to Compress::Zlib and hence to gzip/zlib compressed\nfiles. It provides many of the same methods as the IO::Handle interface.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **CONSTRUCTOR**\n- **OBJECT METHODS**\n- **USING THE EXTERNAL GZIP**\n- **CLASS METHODS**\n- **DIAGNOSTICS**\n- **SEE ALSO**\n- **HISTORY**\n- **COPYRIGHT**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "IO::Zlib",
        "section": "",
        "mode": "perldoc",
        "summary": "IO::Zlib - IO:: style interface to Compress::Zlib",
        "synopsis": "With any version of Perl 5 you can use the basic OO interface:\nuse IO::Zlib;\n$fh = new IO::Zlib;\nif ($fh->open(\"file.gz\", \"rb\")) {\nprint <$fh>;\n$fh->close;\n}\n$fh = IO::Zlib->new(\"file.gz\", \"wb9\");\nif (defined $fh) {\nprint $fh \"bar\\n\";\n$fh->close;\n}\n$fh = IO::Zlib->new(\"file.gz\", \"rb\");\nif (defined $fh) {\nprint <$fh>;\nundef $fh;       # automatically closes the file\n}\nWith Perl 5.004 you can also use the TIEHANDLE interface to access compressed files just like\nordinary files:\nuse IO::Zlib;\ntie *FILE, 'IO::Zlib', \"file.gz\", \"wb\";\nprint FILE \"line 1\\nline2\\n\";\ntie *FILE, 'IO::Zlib', \"file.gz\", \"rb\";\nwhile (<FILE>) { print \"LINE: \", $ };",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 33,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 15,
                "subsections": []
            },
            {
                "name": "CONSTRUCTOR",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "OBJECT METHODS",
                "lines": 46,
                "subsections": []
            },
            {
                "name": "USING THE EXTERNAL GZIP",
                "lines": 14,
                "subsections": []
            },
            {
                "name": "CLASS METHODS",
                "lines": 18,
                "subsections": []
            },
            {
                "name": "DIAGNOSTICS",
                "lines": 41,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "HISTORY",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 3,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "IO::Zlib - IO:: style interface to Compress::Zlib\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "With any version of Perl 5 you can use the basic OO interface:\n\nuse IO::Zlib;\n\n$fh = new IO::Zlib;\nif ($fh->open(\"file.gz\", \"rb\")) {\nprint <$fh>;\n$fh->close;\n}\n\n$fh = IO::Zlib->new(\"file.gz\", \"wb9\");\nif (defined $fh) {\nprint $fh \"bar\\n\";\n$fh->close;\n}\n\n$fh = IO::Zlib->new(\"file.gz\", \"rb\");\nif (defined $fh) {\nprint <$fh>;\nundef $fh;       # automatically closes the file\n}\n\nWith Perl 5.004 you can also use the TIEHANDLE interface to access compressed files just like\nordinary files:\n\nuse IO::Zlib;\n\ntie *FILE, 'IO::Zlib', \"file.gz\", \"wb\";\nprint FILE \"line 1\\nline2\\n\";\n\ntie *FILE, 'IO::Zlib', \"file.gz\", \"rb\";\nwhile (<FILE>) { print \"LINE: \", $ };\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "\"IO::Zlib\" provides an IO:: style interface to Compress::Zlib and hence to gzip/zlib compressed\nfiles. It provides many of the same methods as the IO::Handle interface.\n\nStarting from IO::Zlib version 1.02, IO::Zlib can also use an external gzip command. The default\nbehaviour is to try to use an external gzip if no \"Compress::Zlib\" can be loaded, unless\nexplicitly disabled by\n\nuse IO::Zlib qw(:gzipexternal 0);\n\nIf explicitly enabled by\n\nuse IO::Zlib qw(:gzipexternal 1);\n\nthen the external gzip is used instead of \"Compress::Zlib\".\n",
                "subsections": []
            },
            "CONSTRUCTOR": {
                "content": "new ( [ARGS] )\nCreates an \"IO::Zlib\" object. If it receives any parameters, they are passed to the method\n\"open\"; if the open fails, the object is destroyed. Otherwise, it is returned to the caller.\n",
                "subsections": []
            },
            "OBJECT METHODS": {
                "content": "open ( FILENAME, MODE )\n\"open\" takes two arguments. The first is the name of the file to open and the second is the\nopen mode. The mode can be anything acceptable to Compress::Zlib and by extension anything\nacceptable to *zlib* (that basically means POSIX fopen() style mode strings plus an optional\nnumber to indicate the compression level).\n\nopened\nReturns true if the object currently refers to a opened file.\n\nclose\nClose the file associated with the object and disassociate the file from the handle. Done\nautomatically on destroy.\n\ngetc\nReturn the next character from the file, or undef if none remain.\n\ngetline\nReturn the next line from the file, or undef on end of string. Can safely be called in an\narray context. Currently ignores $/ ($INPUTRECORDSEPARATOR or $RS when English is in use)\nand treats lines as delimited by \"\\n\".\n\ngetlines\nGet all remaining lines from the file. It will croak() if accidentally called in a scalar\ncontext.\n\nprint ( ARGS... )\nPrint ARGS to the file.\n\nread ( BUF, NBYTES, [OFFSET] )\nRead some bytes from the file. Returns the number of bytes actually read, 0 on end-of-file,\nundef on error.\n\neof Returns true if the handle is currently positioned at end of file?\n\nseek ( OFFSET, WHENCE )\nSeek to a given position in the stream. Not yet supported.\n\ntell\nReturn the current position in the stream, as a numeric offset. Not yet supported.\n\nsetpos ( POS )\nSet the current position, using the opaque value returned by \"getpos()\". Not yet supported.\n\ngetpos ( POS )\nReturn the current position in the string, as an opaque object. Not yet supported.\n",
                "subsections": []
            },
            "USING THE EXTERNAL GZIP": {
                "content": "If the external gzip is used, the following \"open\"s are used:\n\nopen(FH, \"gzip -dc $filename |\")  # for read opens\nopen(FH, \" | gzip > $filename\")   # for write opens\n\nYou can modify the 'commands' for example to hardwire an absolute path by e.g.\n\nuse IO::Zlib ':gzipreadopen'  => '/some/where/gunzip -c %s |';\nuse IO::Zlib ':gzipwriteopen' => '| /some/where/gzip.exe > %s';\n\nThe %s is expanded to be the filename (\"sprintf\" is used, so be careful to escape any other \"%\"\nsigns). The 'commands' are checked for sanity - they must contain the %s, and the read open must\nend with the pipe sign, and the write open must begin with the pipe sign.\n",
                "subsections": []
            },
            "CLASS METHODS": {
                "content": "hasCompressZlib\nReturns true if \"Compress::Zlib\" is available. Note that this does not mean that\n\"Compress::Zlib\" is being used: see \"gzipexternal\" and gzipused.\n\ngzipexternal\nUndef if an external gzip can be used if \"Compress::Zlib\" is not available (see\n\"hasCompressZlib\"), true if an external gzip is explicitly used, false if an external gzip\nmust not be used. See \"gzipused\".\n\ngzipused\nTrue if an external gzip is being used, false if not.\n\ngzipreadopen\nReturn the 'command' being used for opening a file for reading using an external gzip.\n\ngzipwriteopen\nReturn the 'command' being used for opening a file for writing using an external gzip.\n",
                "subsections": []
            },
            "DIAGNOSTICS": {
                "content": "IO::Zlib::getlines: must be called in list context\nIf you want read lines, you must read in list context.\n\nIO::Zlib::gzopenexternal: mode '...' is illegal\nUse only modes 'rb' or 'wb' or /wb[1-9]/.\n\nIO::Zlib::import: '...' is illegal\nThe known import symbols are the \":gzipexternal\", \":gzipreadopen\", and\n\":gzipwriteopen\". Anything else is not recognized.\n\nIO::Zlib::import: ':gzipexternal' requires an argument\nThe \":gzipexternal\" requires one boolean argument.\n\nIO::Zlib::import: 'gzipreadopen' requires an argument\nThe \":gzipexternal\" requires one string argument.\n\nIO::Zlib::import: 'gzipread' '...' is illegal\nThe \":gzipreadopen\" argument must end with the pipe sign (|) and have the %s for the\nfilename. See \"USING THE EXTERNAL GZIP\".\n\nIO::Zlib::import: 'gzipwriteopen' requires an argument\nThe \":gzipexternal\" requires one string argument.\n\nIO::Zlib::import: 'gzipwriteopen' '...' is illegal\nThe \":gzipwriteopen\" argument must begin with the pipe sign (|) and have the %s for the\nfilename. An output redirect (>) is also often a good idea, depending on your operating\nsystem shell syntax. See \"USING THE EXTERNAL GZIP\".\n\nIO::Zlib::import: no Compress::Zlib and no external gzip\nGiven that we failed to load \"Compress::Zlib\" and that the use of an external gzip was\ndisabled, IO::Zlib has not much chance of working.\n\nIO::Zlib::open: needs a filename\nNo filename, no open.\n\nIO::Zlib::READ: NBYTES must be specified\nWe must know how much to read.\n\nIO::Zlib::WRITE: too long LENGTH\nThe LENGTH must be less than or equal to the buffer size.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "perlfunc, \"I/O Operators\" in perlop, IO::Handle, Compress::Zlib\n",
                "subsections": []
            },
            "HISTORY": {
                "content": "Created by Tom Hughes <tom@compton.nu>.\n\nSupport for external gzip added by Jarkko Hietaniemi <jhi@iki.fi>.\n",
                "subsections": []
            },
            "COPYRIGHT": {
                "content": "Copyright (c) 1998-2004 Tom Hughes <tom@compton.nu>. All rights reserved. This program is free\nsoftware; you can redistribute it and/or modify it under the same terms as Perl itself.\n",
                "subsections": []
            }
        }
    }
}