[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Binary Files with ASCII headers



Arved Sandstrom wrote:

> For each data file, open it for read, and open two others for write. Read
> in the first 256 bytes, and write it to output file #1. You're now
> positioned at the start of the binary (8-bit ASCII), which you then write
> to output file #2.

I do this kind of thing at work with dBASE files.  My scripts are 
written in Win32 Perl, but the same process should work for you.

For each input file, open with filehandle HANDLE.  Then:

binmode(HANDLE);    # process HANDLE as a binary file
seek(HANDLE,0,0);     # make sure you're at the beginning of the file

After that, you can write the first 256 bytes to file #1 and the rest 
of the data to file #2, as suggested above.

Hope that helps,
Janine

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org