in reply to num keys of the hash within hash?
keys returns a scalar of keys, which you can count with scalar. :-) edit: put a pretty space before keys :-)#!/usr/bin/perl use warnings; use strict; my $hashref = { first => { foo => bar, bar => baz, flop => floodle }, second => { bar => foo, baz => bar, etc => plodle } }; foreach ( keys %{$hashref} ) { print $_ . " contains " . scalar(%{$hashref->{$_}) . " keys.\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: num keys of the hash within hash?
by AnomalousMonk (Archbishop) on May 26, 2009 at 18:20 UTC |