Hashes of Hashes
- From: jcmalburg@xxxxxxxxx (Jason Malburg)
- Date: Thu, 28 Dec 2006 13:03:38 -0800
Hi,
I'm working on a complex data structure with hashes of hashes and
hashes of arrays and I noticed a weird behavior I was hoping someone
could explain. Here's a sample:
$Data{US17}{1}{GROUP} = "STRING";
$Data{US17}{1}{GROUP}{.001} = 5;
$Data{US17}{1}{GROUP}{.002} = 6;
$Data{US17}{1}{GROUP}{.003} = 7;
print "group = $Data{US17}{1}{GROUP}\n";
for my $time (keys %{$Data{US17}{1}{GROUP}}){
print "time = $time $Data{US17}{1}{GROUP}{$time}\n";
}
The output is:
group = STRING
time = 0.002 6
time = 0.003 7
time = 0.001 5
If I swap the order of the declarations, then all of the keys for the
hash under 'GROUP' are wiped out. For example:
$Data{US17}{1}{GROUP}{.001} = 5;
$Data{US17}{1}{GROUP}{.002} = 6;
$Data{US17}{1}{GROUP}{.003} = 7;
$Data{US17}{1}{GROUP} = "STRING";
only produces:
group = STRING
Is this expected behavior? Am I getting lucky in the first instance
with bad syntax that just happens to do what I want?
Thanks in advance,
Jason
.
- Follow-Ups:
- Re: Hashes of Hashes
- From: John W. Krahn
- Re: Hashes of Hashes
- From: Paul Lalli
- Re: Hashes of Hashes
- From: Jen Spinney
- Re: Hashes of Hashes
- Prev by Date: Re: XML in, XML out
- Next by Date: perl extracting substrings from string
- Previous by thread: Deleting files remotely
- Next by thread: Re: Hashes of Hashes
- Index(es):
Relevant Pages
|
|