From: Graham B. <gb...@po...> - 2000-08-15 08:25:39
|
On Mon, Aug 14, 2000 at 10:54:53PM +0100, John Berthels wrote: > > > This email is highlighting more than one issue. Lets break it into parts and > > see what we can develop > > > > 1) Net::LDAP::Entry > > > > In the case of 1) lets list what we should be able to do with an Entry and > > what a newbie would probably expect. Then compare that with what an expert > > would expect/need. It may not be that different. > > Getting data simply > =================== > > This feels too indirect: > > my $msg = $l->search( ... ); > my @entries = $msg->entries(); > foreach my $entry ( @entries ) { > my $attrs = $entry->get( "cn" ); > my $cn = shift @$attrs; # Take first That is what we have now, but I am not sure it is what most would expect when the entry is single-valued, which is probably the most common case. It also leads to ugly code like my $cn = ($entry->get( "cn" ) || [])->[0]; which is even worse. After some thinking I am coming to the idea that is used by DBI. That is that there are several methods with different return type. For example DBI has fetchrow and fetchrow_arrayref, I am thinking we have get and get_arrayref. Get will always return a list of values, non-existant attributes will have to be tested with ->exists Graham. |