It's The Data, Stupid

chaoticset on 2001-11-01T17:35:13

It was, too. I wondered why I couldn't get errors to at least *change* when I modded the code. Pretty simple. I'll explain it to myself for future reference.

First, the good news: The page loads properly again. Bad news: It's not doing what it's supposed to (it's actually printing ARRAY REFERENCES instead of number in stock, but I think I've got a way to fix it). If that resolves today, I'll be happy.

I got the usual errors about uninitialized values in eq statements. Code code code, fiddle fiddle, run. Same errors. Repeat five or ten times, same errors.

The new stock data is formatted:

name=stock=cost=shown

The old one is formatted:

name=stock=cost

I didn't point the file opening sub at the new data file. It was trying to read four things per line out of a file with only three things per line.

Now it's time for a different kind of error. Rooting through the stock file reveals that *a whole bunch of cards have 0 cost values*. That is, they have a 0 for cost.

The code doesn't allow this - I made a sub to handle it quick'n'dirty:

sub myint {

if ($_[0] < 1) { return 1; }

if ( ($_[0] < int $_[0]) && (".5" <= ($_[0] - int $_[0]) )) {
return int ($_[0] + 1) ;
} else {
return int $_[0];
}

}

For now, that takes a possibly decimal amount, converts it to the "nearest dollar amount", and returns an integer value. (Eventually, it'll be a little more sophisticated in its crudeness; it'll round to quarter-dollar amounts. Slightly more elegant mangling.)

I suspect the culprit is this even though I lack proof. (In fact, I'm probably wrong.) Evidence and solutions I go a-searchin' for now...