.if !\nF .nr F 0 ™.. ReadBackwards - Online Linux Manual PageSection : 3pm
Updated : 2018-03-30
Source : perl v5.26.1
Note : User Contributed Perl Documentation

NAMEFile::ReadBackwards.pm −− Read a file backwards by lines.

SYNOPSIS​ use File::ReadBackwards ; ​ ​ # Object interface ​ ​ $bw = File::ReadBackwards−>new( 'log_file' ) or ​ die "can't read 'log_file' $!" ; ​ ​ while( defined( $log_line = $bw−>readline ) ) { ​ print $log_line ; ​ } ​ ​ # ... or the alternative way of reading ​ ​ until ( $bw−>eof ) { ​ print $bw−>readline ; ​ } ​ ​ # Tied Handle Interface ​ ​ tie *BW, 'File::ReadBackwards', 'log_file' or ​ die "can't read 'log_file' $!" ; ​ ​ while( <BW> ) { ​ print ; ​ }

DESCRIPTIONThis module reads a file backwards line by line. It is simple to use, memory efficient and fast. It supports both an object and a tied handle interface. It is intended for processing log and other similar text files which typically have their newest entries appended to them. By default files are assumed to be plain text and have a line ending appropriate to the ​OS. But you can set the input record separator string on a per file basis.

OBJECT INTERFACEThese are the methods in File::ReadBackwards' object interface:

new( $file, [$rec_sep], [$sep_is_regex] )new takes as arguments a filename, an optional record separator and an optional flag that marks the record separator as a regular expression. It either returns the object on a successful open or undef upon failure. $! is set to the error code if any.

readlinereadline takes no arguments and it returns the previous line in the file or undef when there are no more lines in the file. If the file is a non-seekable file (e.g. a pipe), then undef is returned.

getlinegetline is an alias for the readline method. It is here for compatibility with the IO::* classes which has a getline method.

eofeof takes no arguments and it returns true when readline() has iterated through the whole file.

closeclose takes no arguments and it closes the handle

telltell takes no arguments and it returns the current filehandle position. This value may be used to seek() back to this position using a normal file handle.

get_handleget_handle takes no arguments and it returns the internal Perl filehandle used by the File::ReadBackwards object. This handle may be used to read the file forward. Its seek position will be set to the position that is returned by the tell() method. Note that interleaving forward and reverse reads may produce unpredictable results. The only use supported at present is to read a file backward to a certain point, then use 'handle' to extract the handle, and read forward from that point.

TIED HANDLE INTERFACE

tie( *HANDLE, 'File::ReadBackwards', $file, [$rec_sep], [$sep_is_regex] )The TIEHANDLE, READLINE, EOF, CLOSE and TELL methods are aliased to the new, readline, eof, close and tell methods respectively so refer to them for their arguments and API. Once you have tied a handle to File::ReadBackwards the only I/O operation permissible is <> which will read the previous line. You can call eof() and close() on the tied handle as well. All other tied handle operations will generate an unknown method error. Do not seek, write or perform any other unsupported operations on the tied handle.

LINE AND RECORD ENDINGSSince this module needs to use low level I/O for efficiency, it can't portably seek and do block I/O without managing line ending conversions. This module supports the default record separators of normal line ending strings used by the OS. You can also set the separator on a per file basis. The record separator is a regular expression by default, which differs from the behavior of $/. Only if the record separator is not specified and it defaults to ​CR/LF (e.g, VMS, redmondware) will it will be converted to a single newline. Unix and MacOS files systems use only a single character for line endings and the lines are left unchanged. This means that for native text files, you should be able to process their lines backwards without any problems with line endings. If you specify a record separator, no conversions will be done and you will get the records as if you read them in binary mode.

DESIGNIt works by reading a large (8kb) block of data from the end of the file. It then splits them on the record separator and stores a list of records in the object. Each call to readline returns the top record of the list and if the list is empty it refills it by reading the previous block from the file and splitting it. When the beginning of the file is reached and there are no more lines, undef is returned. All boundary conditions are handled correctly i.e. if there is a trailing partial line (no newline) it will be the first line returned and lines larger than the read buffer size are handled properly.

NOTESThere is no support for list context in either the object or tied interfaces. If you want to slurp all of the lines into an array in backwards order (and you don't care about memory usage) just do: ​ @back_lines = reverse <FH>. This module is only intended to read one line at a time from the end of a file to the beginning.

AUTHORUri Guttman, uri@stemsystems.com

COPYRIGHTCopyright (C) 2003 by Uri Guttman. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
0
Johanes Gumabo
Data Size   :   14,625 byte
man-File::ReadBackwards.3pmBuild   :   2024-12-05, 20:55   :  
Visitor Screen   :   x
Visitor Counter ( page / site )   :   6 / 165,577
Visitor ID   :     :  
Visitor IP   :   18.117.145.41   :  
Visitor Provider   :   AMAZON-02   :  
Provider Position ( lat x lon )   :   39.962500 x -83.006100   :   x
Provider Accuracy Radius ( km )   :   1000   :  
Provider City   :   Columbus   :  
Provider Province   :   Ohio ,   :   ,
Provider Country   :   United States   :  
Provider Continent   :   North America   :  
Visitor Recorder   :   Version   :  
Visitor Recorder   :   Library   :  
Online Linux Manual Page   :   Version   :   Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page   :   Library   :   lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page   :   Library   :   lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base   :   Version   :   Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base   :   Library   :   lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36

Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.

ERROR : Need New Coding :         (parse_manual_page_|249|File::ReadBackwards.3pm|36/37|el══─{─══.|.el══─{─══. ds -- \|\(em\| )         (htmlprn|149|File::ReadBackwards.3pm|36/37|.el══─{─══. ds --  —  |.el══─{─══. ds -- \|\(em\| )         (parse_manual_page_|249|File::ReadBackwards.3pm|43|br══─}─══|'br══─}─══ )         (htmlprn|149|File::ReadBackwards.3pm|43|'br══─}─══ |'br══─}─══ )         (rof_nr_x|149|File::ReadBackwards.3pm|57|\nF|.if !\nF .nr F 0 )         (rof_unit_scale_px|41|File::ReadBackwards.3pm|57|F|.if !\nF .nr F 0 )         (rof_if|19|File::ReadBackwards.3pm|57|!\nF|.if !\nF .nr F 0 )         (rof_nr_x|149|File::ReadBackwards.3pm|58/59|\nF>0|.if \nF>0 ══─{─══. de IX )         (rof_unit_scale_px|41|File::ReadBackwards.3pm|58/59|F>0|.if \nF>0 ══─{─══. de IX )         (rof_if|19|File::ReadBackwards.3pm|58/59|\nF>0|.if \nF>0 ══─{─══. de IX )         (htmlprn|149|File::ReadBackwards.3pm|58/59|.if \nF>0 ══─{─══. de IX|.if \nF>0 ══─{─══. de IX )         (rof_escape_sequence|91|File::ReadBackwards.3pm|60|\$1\t\\n%\t"\\$2" |. tm Index:\\$1\t\\n%\t"\\$2" )         (rof_nr_x|149|File::ReadBackwards.3pm|62/63|\nF==2|. if !\nF==2 ══─{─══. nr % 0 )         (rof_unit_scale_px|41|File::ReadBackwards.3pm|62/63|F==2|. if !\nF==2 ══─{─══. nr % 0 )         (rof_if|19|File::ReadBackwards.3pm|62/63|!\nF==2|. if !\nF==2 ══─{─══. nr % 0 )         (htmlprn|149|File::ReadBackwards.3pm|62/63|. if !\nF==2 ══─{─══. nr % 0|. if !\nF==2 ══─{─══. nr % 0 )         (parse_manual_page_|249|File::ReadBackwards.3pm|65|══─}─══|. ══─}─══ )         (htmlprn|149|File::ReadBackwards.3pm|65|. ══─}─══ |. ══─}─══ )         (parse_manual_page_|249|File::ReadBackwards.3pm|66|══─}─══|.══─}─══ )         (htmlprn|149|File::ReadBackwards.3pm|66|.══─}─══ |.══─}─══ )