On 28/4/04 6:56 pm, [EMAIL PROTECTED] <[EMAIL PROTECTED]>
wrote:

> Hi, folks
> 
> I'm somewhat lost with "async" option. I thought that with "async" I'll be
> able to use the data as they come. In particular, I though that this code:
> 
> my $Users = $Ldap->search(async=>1,filter=>'(uid=*)',
>                             scope=>'sub', base=>$base, attrs=>'1.1');
> print "HERE!!!\n";
> foreach my $KMUser ($KMUsers->entries) {
>   printf "Found %s\n", $KMUser->dn;
> }
> 
> Will start spitting out "Found <dn>" lines immediately. In fact, it
> doesn't - there is a rather long sleep period between "Here", and the
> first "Found" line.
> Is it because of the "foreach" loop?

No, it is because calling entries() will block until all the entries have
been returned :-)

Also the async option is only valid in the constructor as it is a per
connection option. You can also call $ldap->async to turn on/off the
connection's async flag. It isn't correct to pass async=>1 in a normal
operation.

You might want to look at the Net::LDAP::Search man page, in particular the
pop_entry() and shift_entry() methods.

Depending on what you're trying to achieve you might also consider passing a
callback to the search method, which will get called as every search result
is returned. See the CALLBACKS section of the Net::LDAP man page for some
details of (oddly enough) callbacks.

Cheers,

Chris

Reply via email to