The error should have clued you in that you have an arrow on the wrong
side of that package name.
The line:
$sorted->Net::LDAP::Control::Sort->new(
should probably read:
$sorted = Net::LDAP::Control::Sort->new(
Using 'strict' would have also thrown you a clue at compile time that
$sorted was never declared. You may want to think about using strict all
the time to prevent such mistakes as these.
--Jonathan Steinert
[EMAIL PROTECTED] wrote:
Hello all,
I've been trying to sort the data returned from my LDAP host, but I get
the following error when I execute my script. Can any help?
I'm a newbie.
"Can't call method "Net::LDAP::Control::Sort" on an undefined value at
./ldapsort.pl line 39, <FH> line 7."
Here is my code
use Net::LDAP qw(:all);
use Net::LDAP::Util qw(ldap_error_text);
use Net::LDAP::Control::Sort;
use Net::LDAP::Constant qw(LDAP_CONTROL_SORTRESULT);
open(FH. "< somefile");
while (<FH>)
{
($iid, $domain, $session, $minutes, $cost) = split(/ */, $line);
$sorted->Net::LDAP::Control::Sort->new(
order => "departmentnumber"
);
$sr = $ldapObject->search(
base=> 'O=Wiley',
scope=> 'sub',
filter=>
"(&(objectclass=jwsPerson)(uid=$iid))",
control => [ $sorted ]
);
($resp) = $sr->control( LDAP_CONTROL_SORTRESULT );
print "Results are sorted\n" if $resp and
!$resp->result;
}
close(FH);