in reply to print array of hashes

In this one record or in all records?

my $kids= scalar @{$rec[0]{kids}};

If you want the sum of kids in all records you just have to add a loop around that line:

my $kids; foreach my $record (@rec) { $kids+= scalar @{$record->{kids}}; }

Replies are listed 'Best First'.
Re^2: print array of hashes
by rovf (Priest) on Apr 22, 2010 at 15:23 UTC
    Maybe we should point out that scalar is not necessary in your case, because you already are in scalar context.

    -- 
    Ronald Fischer <ynnor@mm.st>

      True as that may be, sometimes it feels more comfortable to be explicit about what you mean. For example (and let's keep it simple):

      my $total_price = ($item_price * $item_quantity) + $shipping_cost

      In that example the parentheses aren't necessary because multiplication already has higher precedence than addition anyway, but I feel it improves readability.

Re^2: print array of hashes
by fionbarr (Friar) on Apr 22, 2010 at 12:42 UTC
    thanks Not homework (school-type that is)...but a self-learning session.