On Fri, May 8, 2009 at 03:20, Raymond Wan <rwan.w...@gmail.com> wrote: > Hi Chas, > > On 5/7/09, Chas. Owens <chas.ow...@gmail.com> wrote: >> You use pack to create a binary value and unpack to read a binary >> value. So, to write a file containing three 32 bit integers you say > > [snip] > > Thanks for the sample code; that worked exactly as you said. I wasn't > getting anywhere with google; I thought the key was to get it working > with the b/B [bit string] templates...I wasn't close at all. :-) > > Thanks a lot! > > Ray >
The place to go is http://perldoc.perl.org, and in your case http://perldoc.perl.org/functions/pack.html and http://perldoc.perl.org/functions/unpack.html. You can also get these docs on your machine by saying perldoc -f pack perldoc -f unpack The key with pack and unpack is to use the right template character. In the example, I used l which will turn a Perl number in to a binary signed 32 bit integer. If I had wanted them to be unsigned I could have used L. The documentation for pack lists what the various templates are and what they do. The unpack function uses the same templates, but in reverse. -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/