Well, I did some further investigation and found out that indeed the call to ldapmodify triggers the callback, set in the ldapsearch call, thus resulting in recursion. I put a couple of debug prints in the callback code like this:
printf "aaaaaaaaa\n"; my $modify = $ldap->modify(...); printf "bbbbbbbbb\n"; And this is the output: ... aaaaaaaaa aaaaaaaaa aaaaaaaaa aaaaaaaaa Search complete bbbbbbbbb bbbbbbbbb bbbbbbbbb bbbbbbbbb ... I've also found a decent solution/workaround. I can use two different ldap connections one for the search and the other one for the modify: my $ldap = Net::LDAP->new($ldap_server) or die "$@"; my $ldapm = Net::LDAP->new($ldap_server) or die "$@"; ... $mesg = $ldap->search(..); ... my $modify = $ldapm->modify( ... This works, the only drawback is that the modify rate is now less than half the one with a single connection. This is actually a big slowdown. I would still like to know if there's a better way to do it. thanks g. Giacomo Cerrai wrote: > The code is like: > ... > $mesg = $ldap->search( base => $base_dn, > scope => 'ONE', > filter => "username=*", > attrs => [EMAIL PROTECTED], > callback => \&process_entry > ); > > ... > sub process_entry { > my $mesg = shift; > my $obj = shift; > > if (!$obj) { > print "Search complete\n"; > } > elsif ($obj->isa('Net::LDAP::Reference')) { > ... > } > else { > # don't use $obj, pop_entry it to free memory > my $entry = $mesg->pop_entry; > unless ($entry) { > warn "Cannot pop entry!\n"; > return; > } > ... > my $modify = $ldap->modify( > ... > } > } >