Re: Multiple hosts in an array reference

Christopher A Bongaarts <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.ldap
Message-ID <[email protected]>
In the immortal words of Quanah Gibson-Mount:
> According to the Net::LDAP documentation:
> 
> new ( HOST, OPTIONS )
> 
> HOST may also be a reference to an array of hosts, host-port pairs or URIs 
> to try. Each will be tried in order until a connection is made. Only when 
> all have failed will the result of undef be returned.
[...]
>  $ldap_url = \@ldap_url;
>  print "LDAP URL is now $ldap_url\n";
>  $ldap=Net::LDAP->new("$ldap_url");

Should be checking that $ldap is defined here to avoid the error ;)

> LDAP URL is now ARRAY(0x1a3752c0)

And since you're passing an array referenced *interpolated into a
string*, this will fail unless your LDAP server's hostname happens to
be "ARRAY(0x1a3752c0)".

> Now, if I switch back to just a single URI, things work just fine:
> 
> LDAP URL is ldap://freelancer.lab.zimbra.com:389

Why this prints a string instead of the ARRAY(xxx) I can't figure out.

%%  Christopher A. Bongaarts  %%  [email protected]       %%
%%  Internet Services         %%  http://umn.edu/~cab  %%
%%  University of Minnesota   %%  +1 (612) 625-1809    %%
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.