On Tue, Jul 31, 2001 at 11:31:34AM -0600, Tyler Cruickshank wrote:
> Looking for some binary file help. I want to read, manipulate, and print
> (in ascii) a binary file on a solaris 7 machine. I have looked into and
> tried the binmode() function but this seems to be for older machines that
> differentiate between ascii and binary files. I have tried the following
> and just get the binary form printed back out at me (the expected result):
binmode() is indeed for operating systems that differentiate between ascii
and binary, but such operating systems are not old. Even the newest
versions of Microsoft Windows differentiate; it's a legacy issue.
> open(FILE, "mybinaryfile") || or die "error\n";
> while(<FILE>){
> print "$_\n";
> }
>
> When perl reads a binary file as above, does it understand what it is
> reading? How can I print the file back out in ascii?
You have to make sense of the file; read a chunk at a time and parse it with
unpack. Perl can DWYM quite often, but it's not psychic. :)
Michael
--
Administrator www.shoebox.net
Programmer, System Administrator www.gallanttech.com
--
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]