On 2007-10-28 16:29:21 +0100, Peter J. Holzer wrote:
> On 2007-10-26 19:39:38 -0000, Rob Wilkerson wrote:
> > I can access the value of each member just fine using $mediaref-
> > >{$media_id}->{'ADID'} and I can access the size of the entire record
> > set as keys ( %$mediaref ).  What I need to know, though, is how many
> > elements exist in $mediaref->{$media_id}, but I can't figure out
> > whether that's possible or how to do it.  I've tried all kinds of
> > variations of keys ( %$mediaref->{$mediaid} ) with no luck at all.
> 
>     scalar keys %{ $mediaref->{$mediaid} }
> 
> But I'm quite sure that will return the same number for all rows in the
> query. Maybe you are more interested in the number of fields which are
> not null:
> 
>     scalar grep {
>                   defined $mediaref->{$mediaid}{$_}
>               } keys  %{ $mediaref->{$mediaid} }

Or, a bit simpler:

    scalar grep { defined $_ } values %{ $mediaref->{$mediaid} }

        hp


-- 
   _  | Peter J. Holzer    | If I wanted to be "academically correct",
|_|_) | Sysadmin WSR       | I'd be programming in Java.
| |   | [EMAIL PROTECTED]      | I don't, and I'm not.
__/   | http://www.hjp.at/ |   -- Jesse Erlbaum on dbi-users

Attachment: pgppVLiRPbO8R.pgp
Description: PGP signature

Reply via email to