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

Re: [MacPerl] File reading ?'s



on 6/11/98 12:01 AM , Paul J. Schinder  wrote:

>} I found this function, but don't understand the documentation.  Can you
>} give an example of how unpack might be used in this situation?
>
>Not in this particular situation, since I don't know the structure of this
>particular header.  But suppose you needed to assign the first six bytes of
>the file's contents to six different variables.  You would say something
>like:
>
>read(INFILE,$buf,6)
>
>($one,$two,$three,$four,$five,$six) = unpack("CCCCCC",$buf);
>
>Basically what it does is to split the contents of $buf into pieces
>according to the provided template.  It's by far the easiest way to split
>out something like a header.

Does this split it into Characters, numbers, Hex, or what?  Actually, I 
think that I could do a read for the first 8 bytes.  Included in this 
info is the size of the header.  Then do another read to get the rest of 
the header.  Then I could split it as necessary...  Can you do multiple 
characters in an unpack situation?  One of the variables (the sound 
format) is a 4byte string.

>[snip]
>} >
>} >"Perl for Dummies" really documents read this way?  If so, you need a real
>} >book. Go out and buy "Programming Perl", by Wall, Christiansen & Schwartz
>} >("the Camel"), which is the definitive reference for Perl.
>}
>} Well, if it reads like the Shuck documents, it won't do me any good.  Is
>} this an overtechnical read in which you are already supposed to
>} understand the syntax of Perl in order to get anything out of it?  I
>} wouldn't want the definitive guide to internal combustion engines to find
>} out where the nearest gas station was ;-)
>
>It's the definitive guide to Perl, and one of the authors is the inventor
>of Perl.  It, like the Perl docs if read in order, will teach you Perl.  No
>prior knowledge is necessary, although, as usual, if you've learned a
>programming language before, it helps.  It's much the same in style as the
>documents, because it was written more or less by the same people.

I'll take a look at it.  I think that I saw it at Barnes n Noble last 
time I was there, but was definitely not the "intro" book I wanted.  I 
wanted a book that simply outlined basic Perl methods, functions and 
syntax.  Then I could apply other logics to Perl fairly quickly.  It 
really doesn't help when the book I got (Dummies) is incorrect in its 
explanation of Perl's functions...

>You might also consider buying Chris and Vicki's "MacPerl: Power and Ease",
>but if you're going to seriously use Perl, at some point you either buy the
>Camel or print out all the docs.  

I d/l'd a lot of the MPPE book, and it has some good stuff in it.  If I 
had known about it before, I would definitely gone for it over the 
"Dummies" book.  But it still doesn't talk about the Toolbox calls at all 
(or not enough).  It still refers you to the Inside Mac books...

>Buying the Camel is easier, although at
>this point it is a little out of date.  

How out of date is it?  Are there supplements to it?  It doesn't seem 
very definitive if it is not all-inclusive.

Thanks everyone for the leads...

Jeremy

Jeremy Lee                     |   Owner- 
Sound Designer/Technician      |   Madrone Ridge Sound Design
Oregon Shakespeare Festival    |   Sound for Multimedia
                               |
                 http://www.ashland.net/madrone
-------------------------------------------------------------------------
"Is it not strange that sheeps' guts should hale souls out of men's 
bodies?"  
        -  Wm. Shakespeare

"The mime sang:"  - Alfred Jarry
------------------------


***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch