[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] !fwp: weird behavior with sort and unique-ing



In article <Pine.WNT.4.21.0001201640250.280-100000@nt_alester>,
Andy Lester <andy@petdance.com> wrote:
>> This seems to work as expected except when sort() is used.  The
>> program and output are below, but to make this on-topic, does
>> anyone have any better ways to do this?
>
>Item 4.6 in the Perl Cookbook goes into myriad ways to do it...

Which of course not everybody has.

My favorite way is:

sub uniq(@) {
   my %seen;
   grep !$seen{$_}++, @_
}

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe