On 17/10/03 9:21 pm, Jason Riedel <[EMAIL PROTECTED]> wrote: > All, > > I am having trouble returning a multi-valued attribute's values. My search > query returns about 8 total attributes one of which is a multi-valued > attribute, meaning it contains a dynamic number of values. I can't figure out > nor can I find any documentation on how to return all the values for that > attribute, I can only seem to get the very first value. I am sorry I know this > is an easy one, but I just can't find any documentation on Net-LDAP on > searching multi-valued attributes except for that it is possible. Any help is > appreciated thanks.
To retrieve the values for an attribute, you call $entry->get_value("attr"). The trick is that if you call get_value in a perl scalar context (ie perl knows you only want a single value back), get_value only returns one of the values. If you call get_value in a perl list context (ie perl knows you want multiple values back), get_value returns an array (list) of all the values. This is briefly mentioned in the Net::LDAP::Entry documentation, but you need to read the general perl docs to make complete sense out of it. Anyway, to force array context, try this: my (@vals) = $entry->get_value("attr"); > Jason Riedel > Cheers, Chris