> -----Original Message-----
> From: Sambamoorthy Jayaraman [mailto:[EMAIL PROTECTED]] 
> Sent: Thursday, July 26, 2001 2:32 AM
> To: [EMAIL PROTECTED]
> Subject: Reading binary files
> 
> 
> Hi,
> 
> How do I read a binary file?? From this file, I need to read 
> 16 bit values. 
> I have attached a sample binary file alongwith. When you are 
> reading this 
> file, enable `hex edit mode'.

You need to use the unpack() function.

   perldoc -f unpack

Things to watch out for:

Some evil systems (Windows) have a "text" and "binary" file concept. On
Unix, this is not relevant. See

   perldoc -f binmode

To read fixed length records, see

   perldoc -f read
   perldoc -f sysopen
   perldoc -f sysread

If the file is created on a different architecture, byte ordering may be
different. So a two-byte integer written by an HP PA-RISC (big endian)
system would be interpred wrong when ready by an Intel-based (little endian)
system.

   perldoc perlport (search for "endian")

There are also some FAQ's related:

   perldoc -q binary

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to