in reply to scalar subkeys %hash ?

You need to dereference the hash:

%hash = ( key1 => { subkey1 => 'value1', subkey2 => 'value2', subkey3 => 'Ovid' } ); print scalar keys %{$hash{ key1 }};

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Replies are listed 'Best First'.
Re: (Ovid) Re: scalar subkeys %hash ?
by crazysniffable (Acolyte) on Jun 14, 2001 at 03:51 UTC
    While your suggestion works, it only gives me subkeys for
    the first subhash (key1). Can I get the number of all the subkeys?

    However, I should've been more code specific in that the key
    and subkey names are variables:

    %hash = ( variable_key_name => { variable_subkey_name => somevalue, another_var_subkey => someothervalue, ... }, another_variable_key_name => { variable_subkey => somevalue, variable_subkey2 => anothervalue, ... }, ... );

    Merci beaucoup!