From: Graham B. <gb...@po...> - 2002-04-29 14:15:27
|
On Thu, Apr 25, 2002 at 09:44:42AM +0100, Graham Barr wrote: > > >> sub ldap_explode_dn($%) { > > >> - my $dn = shift or return; > > >> + my @emptydn = (); #empty DN array for scalar context > > >> + my $dn = shift; > > >> + return wantarray ? [] : \@emptydn if $dn eq ''; > > > > > > This does not make sense. You are returning a scalar ref > > > when wantarray is true. Did you mean > > > > > > return wantarray ? () : [] if $dn eq ''; > > > > I'm not that familar with these elements of Perl so it tell you what a I > > actually had in mind: The return value of ldap_explode_dn should give the > > user an indication, whether an invalid DN was passed in. The problem is now > > that the (valid) empty DN '' explodes to an empty array. In the scalar > > context one can return undef or a reference to an empty array but I don't > > know to express this in list context. > > Yup this is a common problem with context sensetive subs. If the user > cares about it they need to call it in a scalar context. For this reason I propose that we remove context sensetivity from ldap_explode_dn and always return an array ref, or undef on error. I belive it was only ever there because ldap_canonical_dn used it, but ldap_canonical_dn can just as easy use an array ref. Graham. |