Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

chaoticset (2105)

chaoticset
  (email not shown publicly)
http://chaoticset.perlmonk.org/
AOL IM: chaoticset23 (Add Buddy, Send Message)
Yahoo! ID: illuminatus_foil (Add User, Send Message)

JAPH. (That's right -- I'm not Really Inexperienced any more.)

I'm not just here, I'm here [perlmonks.org], and here [javajunkies.org] too, I ramble randomly in my philosophical blog [blogspot.com] and my other blog [blogspot.com]. Soon I'll come in a convenient six-pack.

Journal of chaoticset (2105)

Tuesday October 09, 2001
04:34 PM

All Hashed Up

[ #935 ]
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.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.