Well, actually, it's an entry, but it's not a REAL entry, it's...
...okay, I guess it's an entry.
I came to a great conclusion during English class.
"...then comes the fun of sorting it...how on earth am I going to sort this whole mess...?"
So it occurs to me that if I made the whole thing a *circular list of arrays*...
Well, let me explain.
The new inventory is a short, probably alphabetic, list of products (okay, they're Magic The Gathering singles, but I didn't want to refer to something copyrighted in here) and numbers.
The main inventory list itself is also alphabetic (it certainly will be if it's sorted like this every time I add inventory) and it occurred to me when I saw the Cookbook explanation _Implementing A Circular List_, if I had both of them (or even just the main file) set up as a circular list, I could do some nifty things.
The problem was that in addition to adding all the entries, I had to make sure there were no duplicates. My original notion was to solve this with a second pass, dropping the entries into the file in sorted order on the first, then removing duplicates on the second. Bleah. Line this...no fun. Too hard.
Well, the thought came to me that if I do the *pass* into an array of arrays (or possibly a hash, with names for keys and numbers as a list for an entry), I can do all the manipulation I need, then delete the file and dump all the new data in.
Now, it turns out it's going to be easier. If I do the first pass, and *do the comparisons as they are put into the circular list*, I can determine immediately whether I have to add cards and do it to the value when it's set, or add a whole new card altogether.
Which means that the new inventory adder is going to be significantly reduced in size from the 50-60 lines I thought it might become soon. Saved code, saved sanity, and if this all works, I'll feel like I did it right. That's what I'm going to be doing later, once I've got Chinese food here and three or four 2-liter Dew bottles. There will be copious notes.
I love this stuff.