in reply to Re^3: Declaring Hash entries
in thread Declaring Hash entries

Very nice!
but i was at psdevwiki param.sfo, but pretty much same format. In the header (which is 20 bytes long), has the values stored in which to parse the file. All i did was set it up the index table statically in the hash, then if you look, at offset 0x0C is the start of the key table. You can just read the key table 2 bytes at a time until it reaches 2 null characters. Then join all that data, then split on null characters. that will give you the parameters that are loaded in the file.

Then sort it alphabetically, and compare with hash. then print results. I could also add formatting options into the hash as well, and just split it accordingly. Though i am unsure of how to test this code above, it def looks awesome!

Replies are listed 'Best First'.
Re^5: Declaring Hash entries
by Anonymous Monk on Jan 05, 2015 at 08:45 UTC

    excitement ... Though i am unsure of how to test this code above, it def looks awesome!

    Why not?

    Its right there in __END__  perl keytable.pl nonworking.file working.file anyother.file

    My point like always is abstraction (sub sub sub), so that you can just read what you want following the docs of the format ... no copy/paste read statements when you can ReadBytes

      Yeah i did try that, but recieved an error message about expecting $bytes. But never the less, the code i posted works great and pretty quick for what i want to do :)

      Thanks for posting this tho, it will definitely show me a different approach to the same problem. Once i get back i will try to run the code above again to see why it wasnt working for me.

      Thanks! EDIT: Yes, just read bytes, the index table will tell you where each infos are inside the file, all i did was predeclare read lengths, and then i use 0x0C to go to the actual data, then use the predefined read lengths. I will work on this more soon and post a follow up code (which should be alot shorter that my original code).

        Yeah i did try that, but recieved an error message about expecting $bytes.

        Well, you won't get that with the files you posted :) which are small enough to post on perlmonks with Data::Dump::dd() )

        But croaking is there to help; for some reason program couldn't read from the file (past the end?) , so program might as well stop instead of making stuff up and generating a bunch of warnings