File::RandomAccess - Random access reads of sequential file or scalar
use File::RandomAccess; $raf = new File::RandomAccess(\*FILE, $disableSeekTest); $raf = new File::RandomAccess(\$data); $err = $raf->Seek($pos); $num = $raf->Read($buff, $bytes);
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.
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);
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();
Get current position in file
$pos = $raf->Tell();
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);
Read data from the file.
$num = $raf->Read($buff, 1024);
Read a line from file (end of line is $/).
Read whole file into buffer, without changing read pointer.
Set binary mode for file.
Close the file and free the buffer.
Copyright 2003-2015 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.