On Fri, Nov 28, 2008 at 21:43, John J. Foster
<[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I'm using a little perl script
> (http://bsdconsulting.no/tools/mutt-ldap.pl) to query addresses from
> within mutt. I'd like this script to return a sorted list, either by email
> address or name. The little research I've done points to changes in this
> section:
>
> foreach my $entry ($mesg->all_entries) {
> if ($entry->get_value('mail')) {
> print($entry->get_value('mail'),"\t",
> decode("UTF-8", $entry->get_value('cn')),"\tFrom
> Exchange LDAP database\n");
> }
> }
>
> but I can't seem to figure out how. Can anyone point me in the right
> direction?
snip
It looks like you need a schwartzian transform* on the results of
$mesg->all_entries:
#replaces "foreach my $entry ($mesg->all_entries) {"
my @entries =
map { $_->[0] }
sort { $a->[1] cmp $b->[1] }
map { [ $_, $_->get_value('mail') ] }
$mesg->all_entries;
for my $entry (@entries) {
You can sort on names by changing 'mail' to 'cn'.
* http://www.perlfoundation.org/perl5/index.cgi?schwartzian_transform
--
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/