I have the following:
$data{host} -> [$i] -> {someotherstuff}
How can I get the length of the array where [$i] is?
$length = scalar( @{ $data{host} } );
If you want the last index, you can use: $#{ $data{host} }
Obviously, the length of the array is last index + 1. Use this notation when it is harder to achieve scalar context, or when you specifically want length-1. For example:
0..$#{$data{host}} # returns a list of all indices of the array
Sometime useful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With