On Tue, Oct 17, 2000 at 09:49:01PM -0500, tayers@bridge.com wrote: > At the risk of taking this too far... > > We have Ronald's solution (including Steve Lane's one char improvement): > > perl -nle'$h{$r=reverse}?push@w,"$r $_":$h{$_}++}END{map print,sort@w' words > > and Ilmari's solution, which has been disputed: > > perl -nle'$h{$r=reverse}?print"$_ $r":$h{$_}++' words > > But this can be kludged and surprisingly is still shorter: > > sort -r words|perl -nle'$h{$r=reverse}?print"$_ $r":$h{$_}++'|sort > > This also removes Ilmari's assumption that the list is sorted to start > with. ;-) > > Personally I think this goes against the spirit of Perl golf, but I > I agree. :) But as long as you're going to bring in the sort command... perl -nle'$h{$r=reverse}?print"$r $_":$h{$_}++' words|sort There's no need to sort the list twice. > bring this up, because I arrived at the Ilmari solution independently, > (but after Ilmari :-}), so I kind of wanted to defend the "home team." > > And bringing two threads together (the "Wanted - Have = Need" thread's > emphasis on "Perl's not always the best solution"). I suppose there > could be two divisions of Perl golf: > > Pure Perl Golf in which you can only use Perl, no forking, no > piping, just you, Perl and the problem. By 'forking', I assume you mean backticks, system(), or opening a pipe. Calling Perl's fork() function is still pure Perl. > Perl Power Tool Golf in which you can use anything in the PPT, > forking, piping, etc just as long as it would run on pretty much any > platform with the PPT installed. > > Kind of like "clean" and "open" (aka steroids) body building > competitions. ;-) > > P.S. Which reminds me of something I can't remember. Was the use of > modules legal in the Perl Golf Apocalypse? I remember forking wasn't. The use of modules was not allowed. But that reminds me, stay tuned for followup on the Perl Golf Apocalypse... Ronald ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe