Under rare circumstances there could be an error like this:
Can't call method "cookie" without a package or object reference at /home/beni/bin/ldap-preg_replace.pl line 407, <stdin> line 1.</stdin>
This indicates an error with the response handling of the Net::LDAP library. This error is relatively old and long fixed, so you just need to use a fresher perl.
It was confirmed on perl-ldap 0.37-1.19.3 running on a SUSE Linux Enterprise Server 11 SP3.
It was not reproducible anymore on perl-ldap 0.64 (versions in between not tested).
Solution is to update your perl-ldap package to a more recent version.
If you cannot update perl-ldap at this time, try to disable paging with option "-P 0" (see usage for more info).
Diff: