Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

file::randomaccess(3) [suse man page]

File::RandomAccess(3)					User Contributed Perl Documentation				     File::RandomAccess(3)

NAME
File::RandomAccess - Random access reads of sequential file or scalar SYNOPSIS
use File::RandomAccess; $raf = new File::RandomAccess(*FILE, $disableSeekTest); $raf = new File::RandomAccess($data); $err = $raf->Seek($pos); $num = $raf->Read($buff, $bytes); DESCRIPTION
Allows random access to sequential file by buffering the file if necessary. Also allows access to data in memory to be accessed as if it were a file. METHODS
new Creates a new RandomAccess object given a file reference or reference to data in memory. # Read from open file or pipe $raf = new File::RandomAccess(*FILE); # Read from data in memory $raf = new File::RandomAccess($data); Inputs: 0) Reference to RandomAccess object. 1) File reference or scalar reference. 2) flag set if file is already random access (disables automatic SeekTest). Returns: Reference to RandomAccess object. SeekTest Performs test seek() on file to determine if buffering is necessary. If the seek() fails, then the file is buffered to allow random access. SeekTest() is automatically called from new unless specified. $result = $raf->SeekTest(); Inputs: 0) Reference to RandomAccess object. Returns: 1 if seek test passed (ie. no buffering required). Notes: Must be called before any other i/o. Tell Get current position in file $pos = $raf->Tell(); Inputs: 0) Reference to RandomAccess object. Returns: Current position in file Seek Seek to specified position in file. When buffered, this doesn't quite behave like seek() since it returns success even if you seek outside the limits of the file. $success = $raf->Seek($pos, 0); Inputs: 0) Reference to RandomAccess object. 1) Position. 2) Whence (0=from start, 1=from cur pos, 2=from end). Returns: 1 on success, 0 otherwise Read Read data from the file. $num = $raf->Read($buff, 1024); Inputs: 0) Reference to RandomAccess object. 1) Buffer. 2) Number of bytes to read. Returns: Number of bytes actually read. ReadLine Read a line from file (end of line is $/). Inputs: 0) Reference to RandomAccess object. 1) Buffer. Returns: Number of bytes read. Slurp Read whole file into buffer, without changing read pointer. Inputs: 0) Reference to RandomAccess object. Returns: Nothing. BinMode Set binary mode for file. Inputs: 0) Reference to RandomAccess object. Returns: Nothing. Close Close the file and free the buffer. Inputs: 0) Reference to RandomAccess object. Returns: Nothing. AUTHOR
Copyright 2003-2010 Phil Harvey (phil at owl.phy.queensu.ca) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
Image::ExifTool(3pm) perl v5.12.1 2010-01-04 File::RandomAccess(3)

Check Out this Related Man Page

IO::Seekable(3pm)					 Perl Programmers Reference Guide					 IO::Seekable(3pm)

NAME
IO::Seekable - supply seek based methods for I/O objects SYNOPSIS
use IO::Seekable; package IO::Something; @ISA = qw(IO::Seekable); DESCRIPTION
"IO::Seekable" does not have a constructor of its own as it is intended to be inherited by other "IO::Handle" based objects. It provides methods which allow seeking of the file descriptors. $io->getpos Returns an opaque value that represents the current position of the IO::File, or "undef" if this is not possible (eg an unseekable stream such as a terminal, pipe or socket). If the fgetpos() function is available in your C library it is used to implements getpos, else perl emulates getpos using C's ftell() function. $io->setpos Uses the value of a previous getpos call to return to a previously visited position. Returns "0 but true" on success, "undef" on failure. See perlfunc for complete descriptions of each of the following supported "IO::Seekable" methods, which are just front ends for the corresponding built-in functions: $io->seek ( POS, WHENCE ) Seek the IO::File to position POS, relative to WHENCE: WHENCE=0 (SEEK_SET) POS is absolute position. (Seek relative to the start of the file) WHENCE=1 (SEEK_CUR) POS is an offset from the current position. (Seek relative to current) WHENCE=2 (SEEK_END) POS is an offset from the end of the file. (Seek relative to end) The SEEK_* constants can be imported from the "Fcntl" module if you don't wish to use the numbers 0 1 or 2 in your code. Returns 1 upon success, 0 otherwise. $io->sysseek( POS, WHENCE ) Similar to $io->seek, but sets the IO::File's position using the system call lseek(2) directly, so will confuse most perl IO operators except sysread and syswrite (see perlfunc for full details) Returns the new position, or "undef" on failure. A position of zero is returned as the string "0 but true" $io->tell Returns the IO::File's current position, or -1 on error. SEE ALSO
perlfunc, "I/O Operators" in perlop, IO::Handle IO::File HISTORY
Derived from FileHandle.pm by Graham Barr <gbarr@pobox.com> perl v5.16.2 2012-08-26 IO::Seekable(3pm)
Man Page