Hi Mark,
On Friday 29 August 2003 20:43, Mark E. Drummond wrote:
> Just started using perl-ldap (long time perldap user). The examples in
> the docs generally deal with processing multiple entries returned by a
> search, using various loops and such. What if I know a search will
> only return a single entry (search keyed on unique attribute)?
>
> What I am looking for is examples of referencing the various
> hashes/arrays returned in the search without looping through $entries,
> $attrs etc.
Concering the entries thee is no simpler way, since the Net::LDAP::Search
objects return Net::LDAP::Entry objects (and not simple hashes).
But you may check with $result->code() if there was an error and
$result->count() how many entries were found.
[instead of testing for defined($result->entry(0))]
For the values there is help:
Instead of doing everything wit references, why don't you simply use the
values itself:
# get value from entry (set it to empty string if it is not in the entry)
$homedir = $entry->get_value('homedirectory') || '';
print $homedir."\n";
Peter
--
Peter Marschall
eMail: [EMAIL PROTECTED]