GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  FILE::RANDOMACCESS (3)

.ds Aq ’

NAME

File::RandomAccess - Random access reads of sequential file or scalar

CONTENTS

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

<B>newB> 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 or RandomAccess class name.

1) File reference or scalar reference.

2) Flag set if file is already random access (disables automatic SeekTest).

Returns: Reference to RandomAccess object.
<B>SeekTestB> Performs test seek() on file to determine if buffering is necessary. If the seek() fails, then the file is buffered to allow random access. <B>SeekTestB>() is automatically called from <B>newB> 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.
<B>TellB> Get current position in file



    $pos = $raf->Tell();



Inputs: 0) Reference to RandomAccess object.
Returns: Current position in file
<B>SeekB> 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
<B>ReadB> 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.
<B>ReadLineB> Read a line from file (end of line is $/).
Inputs: 0) Reference to RandomAccess object.

1) Buffer.

Returns: Number of bytes read.
<B>SlurpB> Read whole file into buffer, without changing read pointer.
Inputs: 0) Reference to RandomAccess object.
Returns: Nothing.
<B>BinModeB> Set binary mode for file.
Inputs: 0) Reference to RandomAccess object.
Returns: Nothing.
<B>CloseB> Close the file and free the buffer.
Inputs: 0) Reference to RandomAccess object.
Returns: Nothing.

AUTHOR

Copyright 2003-2016 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)
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 FILE::RANDOMACCESS (3) 2016-01-04

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.