Permalink
Browse files

LDAP.pm: avoid warning in new()

Perform substitutions on $h only if it is defined.
  • Loading branch information...
1 parent 9286665 commit e80162e917680f86461ae78239b2c08e2f9eac43 @marschap marschap committed Nov 17, 2012
Showing with 6 additions and 3 deletions.
  1. +6 −3 lib/Net/LDAP.pm
View
@@ -106,10 +106,13 @@ sub new {
foreach my $uri (ref($host) ? @$host : ($host)) {
my $scheme = $arg->{scheme} || 'ldap';
- (my $h = $uri) =~ s,^(\w+)://,, and $scheme = $1;
+ my $h = $uri;
+ if (defined($h)) {
+ $h =~ s,^(\w+)://,, and $scheme = $1;
+ $h =~ s,/.*,,; # remove path part
+ $h =~ s/%([A-Fa-f0-9]{2})/chr(hex($1))/eg; # unescape
+ }
my $meth = $obj->can("connect_$scheme") or next;
- $h =~ s,/.*,,; # remove path part
- $h =~ s/%([A-Fa-f0-9]{2})/chr(hex($1))/eg; # unescape
if (&$meth($obj, $h, $arg)) {
$obj->{net_ldap_uri} = $uri;
$obj->{net_ldap_scheme} = $scheme;

0 comments on commit e80162e

Please sign in to comment.