SPUG: Trouble using a hash
Peter Darley
pdarley at kinesis-cem.com
Thu Nov 20 10:09:11 CST 2003
Keith,
Data Dumper rocks, but don't you need to pass it a scalar? Like print
Dumper(\%trackCircuit)?
Thanks,
Peter Darley
-----Original Message-----
From: spug-list-bounces at mail.pm.org
[mailto:spug-list-bounces at mail.pm.org]On Behalf Of
keith.reed at philips.com
Sent: Wednesday, November 19, 2003 6:17 PM
To: spug-list at mail.pm.org
Subject: Re: SPUG: Trouble using a hash
I like to use Data::Dumper to assist my debugging of hashes.
in the debugger type
x use Data::Dumper;
x print Dumper(%trackCircuit)
You'll get a nicely formatted dump of the hash that might provide some clues
as to where you're going wrong.
Keith
To:
<spug-list at mail.pm.org>
cc: (bcc: Keith
Reed/ATL-BTL/MS/PHILIPS)
Subject: SPUG:
Trouble using a hash
"Curtis Lacy" Classification:
<cel1 at ix.netcom.com>
Sent by:
spug-list-bounces at mail.pm
.org
11/19/2003 05:47 PM
Simple question which I hope someone will take the time to answer. I am
doing a little Perl script to do some studies of thoroughbred horse racing
(what an original idea!). One thing I need to know is when a previous race
was on the same track or on the
same track circuit. [For example, Santa Anita, Hollywood Park, and Del Mar
are all considered to be in the Southern California circuit.]
So I have a hash defined and initialized as follows:
my %trackCircuit = ( Hol=>'SoCal', Aqu=>'NYRA' );
just to give a short sample.
There is an array of items, @LR, which describes the last race run by the
horse. The track is in the first spot, $LR[0].
In the debugger, when I try to step through a line which has a term like
$trackCircuit{ $LR[0] }, it complains about an uninitialized value. I get
the same squawk if I try to do it from the debugger:
p $trackCircuit{ $LR[0] }
Yet, when I do
p $LR[0]
it gives me the correct string "Hol", and if I try
p $trackCircuit{ "Hol" }
it gives the expected "SoCal".
I am at a loss to know what to try next.
Curtis Lacy
cel1 at ix.netcom.com
_____________________________________________________________
Seattle Perl Users Group Mailing List
POST TO: spug-list at mail.pm.org http://spugwiki.perlocity.org
ACCOUNT CONFIG: http://mail.pm.org/mailman/listinfo/spug-list
MEETINGS: 3rd Tuesdays, U-District, Seattle WA
WEB PAGE: http://www.seattleperl.org
_____________________________________________________________
Seattle Perl Users Group Mailing List
POST TO: spug-list at mail.pm.org http://spugwiki.perlocity.org
ACCOUNT CONFIG: http://mail.pm.org/mailman/listinfo/spug-list
MEETINGS: 3rd Tuesdays, U-District, Seattle WA
WEB PAGE: http://www.seattleperl.org
More information about the spug-list
mailing list