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

Re: [FWP] Sort challenge



Uri Guttman <uri@sysarch.com> wrote:

> >>>>> "CRT" == Casey R Tweten <crt@kiski.net> writes:
> 
> 
>   CRT> 84 characters:
> 
>   CRT>     print sort{lc$a cmp lc$b}
>   CRT>     map{/(.*)\|(.*)\|(.*)/;($2?join', ',$2,$3||():$3||$1).$/}<>
> 
>            print sort{lc$a cmp lc$b}
>            map{/(.*)\|(.*)\|(.*)/;($2?"$2${$3&&\qq{, $3}}":$1).$/}<>
> 
> cut off 2 more.

Why all this messing about with join() or, worse, a reference- 
based interpolation, when the straightforward concatenation 
operator gives a solution 5 strokes shorter than Uri's?

           print sort{lc$a cmp lc$b}
           map{/(.*)\|(.*)\|(.*)/;($2?$2.($3&&", $3"):$1).$/}<>

Am I missing something?

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC

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