Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
There's more than one way to do things
 
PerlMonks  

Re: Looping through a binary file

by runrig (Abbot)
on Sep 06, 2013 at 17:04 UTC ( #1052742=note: print w/ replies, xml ) Need Help??


in reply to Looping through a binary file

Your 'while' reads in a line of the file, which, being a binary file, is not what you want to do. You can redefine what a 'line' is by setting $/ (see perlvar). If you set it to a reference to an integer (e.g. $/ = \42;), it will read that many bytes. You can set it to the length of your fixed length record. But then you will have to adjust how you set your variables in the following lines (by using substr or unpack or Parse::FixedLength or something) to 'read' from $_ instead of reading from the filehandle again.


Comment on Re: Looping through a binary file
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2014-04-17 05:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (439 votes), past polls