Frig.

chaoticset on 2002-01-28T04:38:31

First, I thought I'd posted a journal entry about how I thought I'd posted a journal entry.

Second, I managed to leave two pots of water on the stove and not realize I had done so for over half an hour tonight. Or was it three?

I found out why my script, now that I did my hokey little work around (more on that momentarily), managed to increment the cart to 4 when there were only 2 available on the shelf. I forgot to subtract $got from $want before I updated the cart line.

Okay, hokey work-around time. I found out that what I had been using before,

open("filename.thg", FILE)
won't create nonexisting files. That's why the script was always crashing right after the logo and search box; it was checking for a file, not finding it, and wasn't able to create it.

Clearly, I had somehow been appending to the cart before I was reading the cart, which makes sense in my old transfer model; but in the new one, I have to know how many are in the cart before I can decide where anything's going, so I have to read it first. If it's not there, that presents a problem.

So, in desperation to see the script do something properly again, I just added a call to my cart-appending sub in the cart-reading sub. That's as sloppy as using the mayonnaise knife in the peanut butter jar, but at least I know it's that sloppy now.

Knowing is half the battle, or a third of a muffin, or something, right? So that I can MAKE MONKEYS FAST?


nepo

chromatic on 2002-01-28T05:50:51

Looks like you could use the filetest operators (described in perldoc -f -X and perlfunc) and a helpful die with $! (see perlvar). You also have the arguments to open backwards, but that could be a transcription error.

Re:nepo

chaoticset on 2002-01-28T07:20:10

Funny. I did put those down in reverse, didn't I?

I actually had a die, I just didn't do it here. The thing was that $! was "No such file or directory" on die, and I had been using the append open mode to create new cart files if they didn't exist. I made the error of calling the file earlier than I previously ever had.

I got so confused about the open modes that I printed the Camel page it's on, and posted it on the wall next to me. Just called in the wrong order, I think. Once I fix that, the problem will sort itself out.