At 12:09 AM -0300 8/12/99, Sébastien Maury wrote: > Hi, > > I am learning perl to do file manipulation. I managed to do >what I want with text file but I have to convert big (about 100Mo) >text data file (list of points coord.) in binary file. Is it >possible ? For example, I would like to convert line input : > >x = 12.1 y = 13.4 > >in the binary form >XXXX YYYY (float on 4 bytes) > >Is there a special option in the open statement or something like that ? No, there's nothing special that you need to do with open. MacOS, like Unix, doesn't distinguish between text and binary I/O. You use pack(). Pack the two floats into a buffer, and print the buffer. Something like this: ($x, $y) = (something that reads a pair from the text file); $buf = pack("ff",$x,$y); print OUTPUT_BINARY_FILE $buf; To read the file in Perl, use unpack, and of course you'll use read() rather than <> to read the binary file. > >Thanks in advance, Sebastien > >_____________________________________________________________________ >Sebastien Maury CENA division PII >maury@cenatoulouse.dgac.fr 7 avenue Edouard Belin BP 4005 >http://www.cenatoulouse.cena.dgac.fr 31055 Toulouse Cedex, FRANCE >tel : (+33) 05 62 25 96 25 >fax : (+33) 05 62 25 95 99 >_____________________________________________________________________ ----- Paul J. Schinder schinder@pobox.com ===== Want to unsubscribe from this list? ===== Send mail with body "unsubscribe" to macperl-request@macperl.org