Time for another admission:
I'm afraid of hashes.
I know. I hear you, out there, saying that I shouldn't be, but I am. The first time I saw them in _Learning Perl_, they scared me. They still do.
The solutions shown me by the ever-wise Perl Monks all involve hashes. I swear there's a conspiracy brewing somewhere.
(Speaking of brewing, I should get some more coffee. Everything works better with a little coffee.)
I implemented the array-to-hash conversion almost verbatim from one of the helpful explanations:
sub insert_cards {
my %stock = ();
my %shown = ();
foreach my $record (@newcards, @cards) {
my ($name, $stock, $shown) = split(/:/, $record);
$stock{$name} += $stock;
$shown{$name} += "0";
}
foreach $name (keys %stock) {
print ((join(":", $name, $stock{$name}, $shown {$name}))."\n");
}
}
This produces...ALMOST...what I'm trying to do. Lot closer than I got. A finite loop and printed output which is almost what I need, plus an error message:
Use of uninitialized value in join or string at cardhash.p line 74.
with every single piece of output.
I have two options for the rest of the night.
I can either drag out ChessMaster 5000 and get a game in, then go to Chess Night at my local Borders...
or
I can keep working and maybe get this program done, then reward myself around 8:00 with a coffee at said Borders.
Easy option. I just need a little bit of food, and I can get this thing working...and even if I don't, then I can at least bang my head against it for a while longer and try to understand hashes.
Chocolate would be good...I still have a few pieces of Terry's Chocolate Orange, and I love those things.
Coding it is.