Warner, William A wrote: > When I write to a file, most everything goes in as 30 or greater. For > instance, this code: > > > > binmode OUT_FILE; > > syswrite OUT_FILE, 0x0; > > > > Puts a 30 in the DOS debug screen’s left pane and puts a 0 in the DOS > debug’s right screen. > > > > I understand that an ascii zero is represented by a hex 30, but I > expected that outputting a hex value of 0 would give me a hex value into > the file, but instead it gives an ascii 0 value in the file. > > > > I can put one value of less than 30 in the file. I can put a space in > the file which is hex 20 with this code: > > > > binmode OUT_FILE; > > syswrite OUT_FILE, “ “; > > > > since a space is represented by hex 20. How do I put the other 29 values > below 30 into a file?
Use strings or pack rather than scalars : open OUT, ">test.out" or die "create test.out: $! ($^E)"; binmode OUT; syswrite OUT, "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A"; syswrite OUT, "\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x0A"; syswrite OUT, "\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x0A"; syswrite OUT, pack 'CC', 0x1F, 0x20; syswrite OUT, "1234567890\x0A"; close OUT; Results: 000000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f ................ 000010 10 11 12 13 14 0a 15 16 17 18 19 1a 1b 1c 1d 1e ................ 000020 0a 1f 20 31 32 33 34 35 36 37 38 39 30 0a .. 1234567890. -- ,-/- __ _ _ $Bill Luebkert Mailto:[EMAIL PROTECTED] (_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED] / ) /--< o // // Castle of Medieval Myth & Magic http://www.todbe.com/ -/-' /___/_<_</_</_ http://dbecoll.tripod.com/ (My Perl/Lakers stuff) _______________________________________________ Perl-Win32-Users mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
