On Sunday 03 November 2002 11:25, John Pitchko wrote:

Sorry this took me so long to respond to.  Yes, that is part of if not the 
full answer to your question.  You make the data binary before writing it to 
a file.

- Jim

| Ok so then how do I make my data binary? Use pack() and unpack() ?
|
| Thanks.
| --------------------------------------------------------------------------
| John Pitchko
| 3rd Year Computer Science - University of Regina
| Systems Trainee - Data Services - SGI
|
| All e-mails and attachments are certified virus free!
| ----- Original Message -----
| From: "Jim" <[EMAIL PROTECTED]>
| To: "Paul Johnson" <[EMAIL PROTECTED]>
| Cc: <[EMAIL PROTECTED]>
| Sent: Sunday, November 03, 2002 10:31 AM
| Subject: Re: Perl Unix Binary Files
|
| > On Saturday 02 November 2002 18:01, you wrote:
| > | On Sat, Nov 02, 2002 at 04:00:44PM -0600, John Pitchko wrote:
| > | > I've been racking my brains out trying to get Perl to write binary
| > | > files for me. Here is my situation. For my Operating Systems class,
| > | > we are designing a file system. One of the requirements is that the
| > | > file system needs to be saved to disk as a binary file. I have a few
| > | > large array of arrays and hash of hashes in my code, so I was hoping
| > | > to be able to use Data::Dumper to dump and retireve the data
| > | > structures. However, I do not know how to open a file in binary mode
| > | > (from what I understand, binmode() does not work for Unix which is
| > | > the envrionment where I am coding) or write binary data to that file.
| > |
| > | That depends on what you mean by "does not work".  I'll assume you're
| > | not using layers for the moment.  If that is the case, then binmode
| > | doesn't really have any work to do on Unix.  You can just read and
| > | write your binary data.  This has been the case since Perl 3, about 13
| > | years ago I think.
| > |
| > | > I was thinking that I would record the output from Data::Dumper into
| > | > a scalar and write this scalar in binary mode to the disk. Can anyone
| > | > give me any help with this????
| >
| > Afaik, binmode doesn't actually do any binary converting.  It simply
| > makes the data in the filehandle from being tainted (keeping it real) and
| > on the Unix OS's binmode is completely optional although recommended. 
| > So, in
|
| other
|
| > words, if your data isn't already binary then binmode isn't doing
| > anything for you.
| >
| > perldoc  for binmode:
| >
| >  Arranges for FILEHANDLE to be read or written in
| >                "binary" or "text" mode on systems where the run-
| >                time libraries distinguish between binary and text
| >                files.  If FILEHANDLE is an expression, the value
| >                is taken as the name of the filehandle.  DISCI-
| >                PLINE can be either of ":raw" for binary mode or
| >                ":crlf" for "text" mode.  If the DISCIPLINE is
| >                omitted, it defaults to ":raw".
| >
| > | I would suggest taking a look at Storable.
| > |
| > | > All e-mails and attachments are certified virus free!
| > |
| > | Phew!
| >
| > --
| >
| > - Jim
| >
| > --
| > To unsubscribe, e-mail: [EMAIL PROTECTED]
| > For additional commands, e-mail: [EMAIL PROTECTED]

-- 

- Jim

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

Reply via email to