Sorry for the Perl Question, I'm not aware of any good Perl Forums. Plus this is kinda Asm related ;) .

Recently I need to crunch some numbers. I have an ascii data file of the number but I need to rearrange them (put them into a nice table, sort them, etc) before I could process them. Frankly it was proving a b***h do to in asm so I decidied use use PERL to do the rearranging and save the results in a second file ready for the asm program. And it worked grand.

So whats my question? Well a minor upset, I would have liked to use the PERL pack comand to save the results into a binary file as opposed to ascii but it wouldn't work. I wonder if maybe anyone knows what I was doing wrong. Basically the following wouldn't produce the correct file:
foreach $name (sort keys %table) {

print OUT pack("f", $table{$name});
}
Whereas this test would:
foreach $name (sort keys %table) {

print OUT pack("f", 12.34)
}

Printing out the numbers in ascii (without pack) worked grand. With the pack instruction some of the numbers worked, others didn't. The results were pretty strange, I couldn't follow any pattern and the file produced wasn't even a multiple of 4 bytes in length. Are there some numbers which pack messes up on?

Sorry again for the Perl Question, perhaps someone knows of a good Perl Forum. Thanks.
Posted on 2003-03-30 10:29:07 by Eóin
E?in,

personally I like CGI better... but here's a good PERL Forum:

http://www.faqts.com/knowledge_base/index.phtml/fid/200

the format has changed a little since I last visited it... but if you use thier search, they
have many thousands of posts...

ADDED: well, I don't know what happened w/ Faqts.com... I just tried to search for "pack"..
and got nothing... ??? it used to be a Real Good Site... now it's changed?? sorry...



Brad
Posted on 2003-03-30 11:19:04 by Brad
irc.freenode.net, #perl
Posted on 2003-03-30 11:30:09 by bazik
Thanks for the links, hopefully I'll solve the prob, but at least its not the end of the world :) .
Posted on 2003-03-31 11:00:25 by Eóin