What I wrote is slightly misleading. The first hash has several entities, one of which is 'object'. Inside this hash, I have several other hashes, all of which are actually named '0' and up.
I guess I overlooked just iterating through that second hash. I am now stuck in leveraging those hashes as the syntax is eluding me. The hashes I will use are $workspace->{Object}->{0} up to $workspace->{Object}->{n}. All the examples on the net I have found don't show referencing hashes in this manner. Since it is a hash I have (coincident they are named 0 and up) I would use a while/each, so how does one write that? As an example While ($workspace->{stuff}) { print "$workspace->{stuff}->{"Iterated element"}->{type}\n"; } Thanks! jlc -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tom Phoenix Sent: October-19-07 3:32 PM To: Joseph L. Casale Cc: beginners@perl.org Subject: Size of a hash On 10/19/07, Joseph L. Casale <[EMAIL PROTECTED]> wrote: > Is there a way to compute the size of a hash? Yes; use the keys() function in a scalar context to get the number of key-value pairs in the hash. my $count = keys %hash; > I have a hash of hashes of hashes etc... and need to know how > many items exist in the second hash. I know they are always > named as integers from 0 up. Now it sounds as if you're talking about arrays. Hash elements aren't numbered, but array indices start at zero. > Does such a method exist, or is there a better way? Could I > reliably just start the loop and expect a certain error I could > trap and stop on once I increment the hash value up to far > instead? To iterate through an entire hash, use while/each: my %hash = qw/ Chicago 25 Atlanta 18 Portland 29 /; while (my($key, $value) = each %hash) { print "The key is $key and the value is $value.\n"; } But it still sounds as if you're really asking about an array. If you're iterating through an array, use foreach. Hope this helps! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/