From: Graham B. <gb...@po...> - 2001-05-31 06:59:34
|
On Thu, May 31, 2001 at 03:01:26PM +1200, Simon Allard wrote: > Thanks for the Reply Graham. > > Callbacks sound like a great idea, but I am not having much luck with > them. There isn't much documentation about them. I have tried in on my > Solaid box with perl 5.003 and my Debian box with perl 5.6 and get the > same result. > > Source follows: > $ldap->search( > base => "$authbase", > filter => '(objectclass=ihugAuthAccount)', > callback => &check_oracle() > ); You need to pass a reference to the sub. This calls the sub and passes its result. callback => \&check_oracle > sub check_oracle { > my ($mesg, $entry) = @_; > > $entry->dump(); > } Entry will not be defined on the last call, so make sure you check it is defined. Also to save memoery you need to tell Net::LDAP to remove it from the list. sub check_oracle { my ($mesg, $entry) = @_; if ($entry and $entry->isa('Net::LDAP::Entry')) { $entry->dump(); $mesg->pop_entry; } } Graham. |