Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: How smart is 'seek $fh, $pos, 0'?

by MidLifeXis (Monsignor)
on May 27, 2015 at 13:01 UTC ( [id://1127991]=note: print w/replies, xml ) Need Help??


in reply to How smart is 'seek $fh, $pos, 0'?

Doing this from memory - sorry, cannot find a source reference (which would be the ideal authority for your question). Given some of the grey hair now showing on my head, I have to ask - what device do you have open and are calling a seek() against? If it were an old tape drive (perhaps even new ones?) or other sequential access medium, you would need to seek to the beginning of file then to the position. Given a random access medium, you can "simply" (with a bit of additional housekeeping around buffers and such) reset the current file pointer on the handle. So, "It Depends™". [update] Additionally, some devices do not allow seeking backwards and will throw an error if attempted.

--MidLifeXis

Replies are listed 'Best First'.
Re^2: How smart is 'seek $fh, $pos, 0'?
by Monk::Thomas (Friar) on May 27, 2015 at 13:18 UTC

    This question is not backup-related so thankfully I don't have to concern myself with tape drives. The code is expected to handle a specific file format (Bethesda .esm and .esp files) and therefor the filehandle is expected to point to a file on a random access media (disk drive).

    The most common case would be sequentially processing the records, but I'd like to also be able to process the records out of order (e.g. skip uninteresting ones).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1127991]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-04-24 08:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found