{
    "content": [
        {
            "type": "text",
            "text": "# File::ReadBackwards (perldoc)\n\n## NAME\n\nFile::ReadBackwards.pm -- Read a file backwards by lines.\n\n## SYNOPSIS\n\nuse File::ReadBackwards ;\n# Object interface\n$bw = File::ReadBackwards->new( 'logfile' ) or\ndie \"can't read 'logfile' $!\" ;\nwhile( defined( $logline = $bw->readline ) ) {\nprint $logline ;\n}\n# ... or the alternative way of reading\nuntil ( $bw->eof ) {\nprint $bw->readline ;\n}\n# Tied Handle Interface\ntie *BW, 'File::ReadBackwards', 'logfile' or\ndie \"can't read 'logfile' $!\" ;\nwhile( <BW> ) {\nprint ;\n}\n\n## DESCRIPTION\n\nThis module reads a file backwards line by line. It is simple to use, memory efficient and fast.\nIt supports both an object and a tied handle interface.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **OBJECT INTERFACE**\n- **TIED HANDLE INTERFACE**\n- **LINE AND RECORD ENDINGS**\n- **DESIGN**\n- **NOTES**\n- **AUTHOR**\n- **COPYRIGHT**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "File::ReadBackwards",
        "section": "",
        "mode": "perldoc",
        "summary": "File::ReadBackwards.pm -- Read a file backwards by lines.",
        "synopsis": "use File::ReadBackwards ;\n# Object interface\n$bw = File::ReadBackwards->new( 'logfile' ) or\ndie \"can't read 'logfile' $!\" ;\nwhile( defined( $logline = $bw->readline ) ) {\nprint $logline ;\n}\n# ... or the alternative way of reading\nuntil ( $bw->eof ) {\nprint $bw->readline ;\n}\n# Tied Handle Interface\ntie *BW, 'File::ReadBackwards', 'logfile' or\ndie \"can't read 'logfile' $!\" ;\nwhile( <BW> ) {\nprint ;\n}",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 26,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 7,
                "subsections": []
            },
            {
                "name": "OBJECT INTERFACE",
                "lines": 35,
                "subsections": []
            },
            {
                "name": "TIED HANDLE INTERFACE",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "LINE AND RECORD ENDINGS",
                "lines": 14,
                "subsections": []
            },
            {
                "name": "DESIGN",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "NOTES",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 3,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "File::ReadBackwards.pm -- Read a file backwards by lines.\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use File::ReadBackwards ;\n\n# Object interface\n\n$bw = File::ReadBackwards->new( 'logfile' ) or\ndie \"can't read 'logfile' $!\" ;\n\nwhile( defined( $logline = $bw->readline ) ) {\nprint $logline ;\n}\n\n# ... or the alternative way of reading\n\nuntil ( $bw->eof ) {\nprint $bw->readline ;\n}\n\n# Tied Handle Interface\n\ntie *BW, 'File::ReadBackwards', 'logfile' or\ndie \"can't read 'logfile' $!\" ;\n\nwhile( <BW> ) {\nprint ;\n}\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This module reads a file backwards line by line. It is simple to use, memory efficient and fast.\nIt supports both an object and a tied handle interface.\n\nIt is intended for processing log and other similar text files which typically have their newest\nentries appended to them. By default files are assumed to be plain text and have a line ending\nappropriate to the OS. But you can set the input record separator string on a per file basis.\n",
                "subsections": []
            },
            "OBJECT INTERFACE": {
                "content": "These are the methods in \"File::ReadBackwards\"' object interface:\n\nnew( $file, [$recsep], [$sepisregex] )\n\"new\" takes as arguments a filename, an optional record separator and an optional flag that\nmarks the record separator as a regular expression. It either returns the object on a successful\nopen or undef upon failure. $! is set to the error code if any.\n\nreadline\n\"readline\" takes no arguments and it returns the previous line in the file or undef when there\nare no more lines in the file. If the file is a non-seekable file (e.g. a pipe), then undef is\nreturned.\n\ngetline\n\"getline\" is an alias for the readline method. It is here for compatibility with the IO::*\nclasses which has a getline method.\n\neof\n\"eof\" takes no arguments and it returns true when readline() has iterated through the whole\nfile.\n\nclose\n\"close\" takes no arguments and it closes the handle\n\ntell\n\"tell\" takes no arguments and it returns the current filehandle position. This value may be used\nto seek() back to this position using a normal file handle.\n\ngethandle\n\"gethandle\" takes no arguments and it returns the internal Perl filehandle used by the\nFile::ReadBackwards object. This handle may be used to read the file forward. Its seek position\nwill be set to the position that is returned by the tell() method. Note that interleaving\nforward and reverse reads may produce unpredictable results. The only use supported at present\nis to read a file backward to a certain point, then use 'handle' to extract the handle, and read\nforward from that point.\n",
                "subsections": []
            },
            "TIED HANDLE INTERFACE": {
                "content": "tie( *HANDLE, 'File::ReadBackwards', $file, [$recsep], [$sepisregex] )\nThe TIEHANDLE, READLINE, EOF, CLOSE and TELL methods are aliased to the new, readline, eof,\nclose and tell methods respectively so refer to them for their arguments and API. Once you have\ntied a handle to File::ReadBackwards the only I/O operation permissible is <> which will read\nthe previous line. You can call eof() and close() on the tied handle as well. All other tied\nhandle operations will generate an unknown method error. Do not seek, write or perform any other\nunsupported operations on the tied handle.\n",
                "subsections": []
            },
            "LINE AND RECORD ENDINGS": {
                "content": "Since this module needs to use low level I/O for efficiency, it can't portably seek and do block\nI/O without managing line ending conversions. This module supports the default record separators\nof normal line ending strings used by the OS. You can also set the separator on a per file\nbasis.\n\nThe record separator is a regular expression by default, which differs from the behavior of $/.\n\nOnly if the record separator is not specified and it defaults to CR/LF (e.g, VMS, redmondware)\nwill it will be converted to a single newline. Unix and MacOS files systems use only a single\ncharacter for line endings and the lines are left unchanged. This means that for native text\nfiles, you should be able to process their lines backwards without any problems with line\nendings. If you specify a record separator, no conversions will be done and you will get the\nrecords as if you read them in binary mode.\n",
                "subsections": []
            },
            "DESIGN": {
                "content": "It works by reading a large (8kb) block of data from the end of the file. It then splits them on\nthe record separator and stores a list of records in the object. Each call to readline returns\nthe top record of the list and if the list is empty it refills it by reading the previous block\nfrom the file and splitting it. When the beginning of the file is reached and there are no more\nlines, undef is returned. All boundary conditions are handled correctly i.e. if there is a\ntrailing partial line (no newline) it will be the first line returned and lines larger than the\nread buffer size are handled properly.\n",
                "subsections": []
            },
            "NOTES": {
                "content": "There is no support for list context in either the object or tied interfaces. If you want to\nslurp all of the lines into an array in backwards order (and you don't care about memory usage)\njust do:\n\n@backlines = reverse <FH>.\n\nThis module is only intended to read one line at a time from the end of a file to the beginning.\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "Original author: Uri Guttman, \"uri@stemsystems.com\"\n\nCurrent maintainer: Graham Ollis \"plicease@cpan.org\"\n",
                "subsections": []
            },
            "COPYRIGHT": {
                "content": "Copyright (C) 2000-2021 by Uri Guttman. All rights reserved. This program is free software; you\ncan redistribute it and/or modify it under the same terms as Perl itself.\n",
                "subsections": []
            }
        }
    }
}