Beast am Mittwoch, 31. Mai 2006 07.59:
> Hi,

Hi

> I have some rather big chunk of data, returned 

How 'returned'?

> from ldap server. The 
> format is simple:
> "Displa name" <[EMAIL PROTECTED]>
>
> Simply displying 

in the sense of printing to STDOUT?

> data "as is" is simple, but how do I sorted  by 
> "display name"?
> pls note that "display name" contains space and might not unique so I
> can't put it on %hash.

Hash keys _can_ contain spaces:

$ perl -Mstrict -Mwarnings -le 'my $key=q(<with spaces >); \
  my %h=($key=>q(<value>)); print %h'


and if you have multiple values to one key, 
you can use an arrayref as hash value to accumulate the values:

push @{$hash{$displayname}}, $emailaddress;
# instead of
$hash{$displayname}=$emailaddress;


But if you simply want a sorted display of the lines:

print sort @lines;

This would sort by display name on the first level, and for convenience also 
by address on the second.

But the easiest way may be to simply sort in the shell:

$ app_printing_the_ldap_lines_to_STDOUT | sort

Hope this helps.

Dani

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to