Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: Perl binary file reading

by Marshall (Canon)
on May 02, 2016 at 22:36 UTC ( [id://1162046]=note: print w/replies, xml ) Need Help??


in reply to Re: Perl binary file reading
in thread Perl binary file reading

If using a console text input stream, a ^D on Unix or a ^Z on Windows will indeed result in an EOF for the user program.

With an HD file, there is no such a thing! Because all files are binary on the hard disk. The file system returns "end of file" to the function reading when all bytes (in the intrinsically binary file) on disk are consumed. The file system always calculates EOF based upon number of bytes in the file. There is no ^D or ^Z at the "end of the file". This is needed for a text input stream because there is no limit on the number of bytes (characters).

Using read and a big buffer like 50 MB could be ok on a modern computer. Reading in smaller chunks is fine, but more complicated.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-24 04:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found