in reply to find a number of keys in a hash

Actually you got 1 less than the number of keys because arrays are zero based, but that's a different problem. If you read the keys documentation the second sentence explains that calling it in scalar context returns the number of keys: my $num_keys = keys %data.

The cake is a lie.
The cake is a lie.
The cake is a lie.

Replies are listed 'Best First'.
Re^2: find a number of keys in a hash
by MidLifeXis (Monsignor) on Jan 16, 2009 at 19:35 UTC

    Or the last index of the array (if you change $[)

    --MidLifeXis