|
File::RandomAccess - Random access reads of sequential file or scalar |
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.
# Read from open file or pipe
$raf = new File::RandomAccess(\*FILE);
# Read from data in memory
$raf = new File::RandomAccess(\$data);
1) File reference or scalar reference.
2) flag set if file is already random access (disables automatic SeekTest).
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();
$pos = $raf->Tell();
seek() since it returns success even if you seek outside the
limits of the file.
$success = $raf->Seek($pos, 0);
1) Position.
2) Whence (0=from start, 1=from cur pos, 2=from end).
$num = $raf->Read($buff, 1024);
1) Buffer.
2) Number of bytes to read.
1) Buffer.
Copyright 2004-2006 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.
|
File::RandomAccess - Random access reads of sequential file or scalar |