Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Number of key in Array of hash

by Sun751 (Beadle)
on Jul 23, 2009 at 00:26 UTC ( [id://782502]=perlquestion: print w/replies, xml ) Need Help??

Sun751 has asked for the wisdom of the Perl Monks concerning the following question:

I have and array @ABC where each element is a hash, can some one suggest me if I want to find out number of hash key in last array element how can I do that?
I know that I can access the hash key of last array element through $name = $ABC::ABC-1->{'Name'}
Any suggestion?Please
Cheers

Replies are listed 'Best First'.
Re: Number of key in Array of hash
by roubi (Hermit) on Jul 23, 2009 at 00:29 UTC
    my @array; ... my $key_count = keys %{$array[-1]};
Re: Number of key in Array of hash
by Anonymous Monk on Jul 23, 2009 at 00:37 UTC
Re: Number of key in Array of hash
by susanti13 (Novice) on Jul 23, 2009 at 01:05 UTC
    my $lastIndex = (scalar @ABC) - 1; my $totalKeys = scalar keys %{$ABC[$lastIndex]};
      All these are equivalent
      my $totalKeys = scalar keys %{$ABC[-1]}; my $totalKeys = keys %{$ABC[-1]}; my $totalKeys = 0 + keys %{$ABC[-1]};

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://782502]
Approved by AnomalousMonk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-19 05:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found