Coming from a C programmer who just finished Larry Wall's book, there is but one thing to say about Perl:
Pure, Unadulterated, Blinding Brilliance.
My head is Spinning.
'unless' really threw me for a loop; I thought it was a typo!
Now for the question:
I'm looking to rewrite some of my C programs in order to practice Perl; however, most of the 'meaty' ones that I have access to at work involve sequential-file record parsing. I typically have a data structure that contains all the fields that I expect to see in the sequential file - then I read each record into a buffer, and memcpy() the buffer into the data structure (the structure mirrors the format of each record).
I have an array of these structures, with each item in the array containing the now-useful data from one record in the sequential file. Now I can use array.member to access some needed piece of data, or iterate through the whole shebang to dump the data to a database-friendly file.
Looking back on what I've learned from the Perl book, I would use an associative array to hold the data from each record. But this seems silly; I would have to
a) have an array of associative arrays (in C, an array of structs)
b) read each record into some variable
b) address each Key of each associative array [b]by name[/b] and copy the data from a certain chunk of the variable (using substr())into the Value piece of the associative array. And I don't even know how substr() would handle binary data (ascii 0 etc..).
Is C the proper language to do this efficiently? Or am I completely wrong about the proper way to do this using Perl? (I am hoping that the latter is true; I can't wait to get started)