Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't call method "blah" without a package or object reference

Status
Not open for further replies.

rotis23

Programmer
Aug 29, 2002
121
GB
Hi All,

I'm getting this problem intermittenly i.e. it works for the first few runs, then it fails.

Getting this error:

Can't call method "entry" without a package or object reference at ... (the first entry call in the if test)

with the following code
Code:
undef $mesg;

eval
{
         $mesg = $ldap->search (
               base => "ou=my,dc=domain,dc=com",
               filter => "(mail=$recipient)",
               attrs  => ['l']
               ) || undef $mesg;

         if(defined($mesg) && $mesg->entry(0))
         {
               $My_Location = $mesg->entry(0)->get_value('l');
         }
         else
         {
               $Unknown = 1;
         }
};

if($@)
{
         print "LDAP Error: $@\n";
}
How can I handle this (and set $Unknown = 1) without the eval statement throwing the error?

TIA, rotis23
 
I think this:-

if(defined($mesg) && $mesg->entry(0))
{


should be:-

if(defined($mesg))
{
if ($mesg->entry(0))
{
....


At least, that's how I'd do it, as if $mesg is not defined, then the 2nd condition would cause an error.

HTH,

Mark.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top