Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
So the question is, is there an idiom that would simplify or at least make the following code (particulary within the for loop) easier to read? BTW, the code below runs with no errors or warnings and the results appear to be correct.Can't use an undefined value as an ARRAY reference at ldap.test2.pl li +ne xx.
Thanks for any and all feedback.use strict; use warnings; use Net::LDAP; use Net::LDAP::Util qw / ldap_error_text /; use Net::LDAP::Schema; use Net::LDAP::Entry; use Net::LDAP::Search; use Data::Dumper; ## snip my @vars = qw( cn mail ); ## this will have about 30 fields eventuall +y my %uids; for my $entry ($searchresult->entries) { my $uid = ''; $uid = ${$entry->get('uid')}[0] if defined $entry->get('uid'); if ($uid) { for (@vars) { $uids{$uid}{$_} = ''; $uids{$uid}{$_} = ${$entry->get($_)}[0] if defined $entry->get($_); } } else { print "*** No uid for the following entry:\n"; print Dumper(\$entry); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: About BLOCK variables
by Abigail-II (Bishop) on May 23, 2003 at 22:16 UTC | |
|
Re: About BLOCK variables
by theorbtwo (Prior) on May 23, 2003 at 23:00 UTC | |
by Anonymous Monk on May 24, 2003 at 06:48 UTC | |
|
Re: About BLOCK variables
by BrowserUk (Patriarch) on May 23, 2003 at 23:06 UTC | |
by Anonymous Monk on May 23, 2003 at 23:37 UTC | |
by BrowserUk (Patriarch) on May 24, 2003 at 01:05 UTC | |
by BrowserUk (Patriarch) on May 24, 2003 at 01:27 UTC | |
by Anonymous Monk on May 24, 2003 at 06:22 UTC |