mt2k has asked for the wisdom of the Perl Monks concerning the following question:
$db{'key1'}{'key2'}[0][0] = "one_value"; $db{'key1'}{'key2'}[0][1] = "two_value"; $db{'key1'}{'key2'}[1][0] = "three_value"; $db{'key1'}{'key2'}[1][1] = "four_value"; $db{'key1'}{'key2'}[2][0] = "three_value"; $db{'key1'}{'key2'}[2][1] = "four_value";
Or maybe like this, I'm not sure:
@{$db{'key1'}{'key2'}[0][0]} = "one_value"; @{$db{'key1'}{'key2'}[0][1]} = "two_value"; @{$db{'key1'}{'key2'}[1][0]} = "three_value"; @{$db{'key1'}{'key2'}[1][1]} = "four_value"; @{$db{'key1'}{'key2'}[2][0]} = "three_value"; @{$db{'key1'}{'key2'}[2][1]} = "four_value";
Now, under the key2 key, I don't know how many values are in that array. (The first set of array numbers, namely 0, 1, and 2). The second set of array numbers (The constant 0 and 1) are always there and only have the indexes 0 and 1.
Could someone please give me an idea what this hash structure would look like, and how I would go about getting the last index number of the first set of array numbers. (Something like $#{$db{'key1'}{'key2'}} maybe?)
And also, how would I go about deleting the array? I don't want to do delete $db{'key1'}{'key2'}, but something more along the lines of delete $db{'key1'}{'key2'}[3].
Thanks ahead of time!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Array in a Hash
by mstone (Deacon) on Dec 14, 2001 at 04:08 UTC | |
|
Re: Array in a Hash (boo);
by boo_radley (Parson) on Dec 14, 2001 at 03:02 UTC | |
|
Re: Array in a Hash
by premchai21 (Curate) on Dec 14, 2001 at 08:14 UTC | |
|
Re: Array in a Hash
by mt2k (Hermit) on Dec 14, 2001 at 19:29 UTC | |
by boo_radley (Parson) on Dec 14, 2001 at 19:50 UTC |