On May 19, Ramprasad A Padmanabhan said:
>#!/usr/bin/perl
>
>my @arr = qw(a b c d a b e f );
>print join(" " , sort @arr) . "\n" . '#' x 50 . "\n";
>print join(" " , sort (uniq (@arr))) . "\n";
>exit 0;
>sub uniq{keys%{{map{$_,[EMAIL PROTECTED]
Perl is not sorting the return values of the uniq() function, Perl is
using 'uniq' as the comparison function to sort(). This is *ALL* because
you have a space after the function name. If you did
sort(uniq(@arr))
or
sort +uniq(@arr)
you'd print the sorted unique values.
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
CPAN ID: PINYAN [Need a programmer? If you like my work, let me know.]
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>