I have some new code that searches my company's LDAP directory,
returning the old classics of name, phone number, email, and so on.
The problem is, if an attribute can have more than one value, I can
only seem to get at one of them. How do I access the 2nd, 3rd,
etc. values in an attribute if there's more than one? Is there a way
to tell that there *is* more than one value in a given attribute?
Here's a code snippet--again, this works, but only grabs the first
value . . .
my @entries = $mesg->entries;
if ( $layout eq 'tel' ) {
my @attributes = qw(cn uid pager telephoneNumber);
my $format = "%-20s %-12s %-15s %s\n";
printf $format, qw(Name E-Mail Pager Phone);
print '-' x 75, "\n";
foreach my $entry ( @entries ) {
my @line;
foreach my $attribute ( @attributes ) {
push @line, ( $entry->get_value($attribute) || 'none' );
}
printf $format, @line;
}
}
Multiple calls to $entry->get_value('telephoneNumber'), for
example, don't get successive values. I'd be most grateful for any
help that anyone may be able to give.
--TQuid
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.