Friday Perl Challenge

Eric Wilhelm scratchcomputing at gmail.com
Fri Apr 20 18:49:18 BST 2007


# from Joel Bernstein
# on Friday 20 April 2007 02:13 am:

>perl -nle 'map{$X{$_}++}split/\s+/}{print"$_:$X{$_}"for sort keys%X'

Nice.

I decided to go OO, which means I totally bomb the #2, but I
should still get my #3 bonus because he didn't say anything about
methods.

 export PERL5OPT='-Mlist=L,F'
 perl -ln0e 'print for L(split)->map(F{$X{$_}++?():$_})->sort->map(F{"$_:$X{$_}"})->l'

Too bad about the counting though.  I guess list.pm needs
something for that.

  L(split)->sort->uniq->l

--Eric
-- 
"You can't win. You can't break even. You can't quit."
--Ginsberg's Restatement of the Three Laws of Thermodynamics
---------------------------------------------------
    http://scratchcomputing.com
---------------------------------------------------


More information about the london.pm mailing list