perl - return an object from subroutine - Net::LDAP

Hi all,
I'm not even sure a person can do this in perl, seems like you should be able to though.
Here's the error

IO::Socket::INET: connect: Operation now in progress at server_search.pl line 256, <DATA> line 466.

Here's the perl code...

sub ldap_new{
   $nl = Net::LDAP->new( "$_[0]" ) or die "$@";
   return $nl;
}

$ldap_realm = ldap_new("realm_server");

There's more code I've got using subroutines for my ldap work since I've got a couple different realms to spin through to find the correct ou for the server in the list.... but it's bombing before it even gets to those.

Any help would be appreciated, thanks much!

Try:

sub ldap_new{
   my $nl = Net::LDAP->new( "$_[0]" ) or die "$@";
   return $nl;
}

Changed it to use my, still failing. Though, that is the exact line it's bombing on.

---------- Post updated at 06:02 PM ---------- Previous update was at 05:41 PM ----------

Also, to add, I don't get this error message if I don't use a subroutine. I could change it quite easily... but, it's a matter of wills now. :slight_smile:

---------- Post updated at 07:00 PM ---------- Previous update was at 06:02 PM ----------

Ok, get this noise. So I broke the code out into a small test program and then added in my subroutines line by line. Since I was testing I decided to use a test server that I knew was bound to a particular ou... darn thing worked right off the bat! It was failing because the server was empty. Since there shouldn't be any empty elements of the array I'm using I'm going to have to look at that... but... that's what was happening.

Anywho... back to the code. :slight_smile:

Just in case anybody else ever runs into this issue or is looking for a way to use Net::LDAP with perl I put together a post on my blog that folks can use. Not to mention, it helps me remember just what the heck I did! It can be found here. Perl Net::LDAP

Oh, and I apologize for the site in advance. I have plans to put together a bunch of tutorials eventually... but for now it's just a blog site that I'm using to write about things I run into. :slight_smile: