[SPOILER] Minimalistic (but CPAN-enabled) solution

Shlomi Fish <shlomif-ik1l9ssToec+JF/[email protected]> Tue, 25 Jan 2005 04:41:12 +0200
Newsgroups gmane.comp.lang.perl.qotw.discuss
Message-ID <[email protected]>
Here's a solution using IO::All and the Uniq modules which implements the uniq 
function:

<<<
#!/usr/bin/perl

use strict;
use warnings;
use IO::All;
use Uniq;

io($ARGV[1])->print(uniq(
    sort { $a cmp $b }
    map { my $s = $_; $s=~s{[A-Z]$}{M}; ($_, $s) }
    io($ARGV[0])->getlines()
    ));
>>>

There's exactly one statement except for all the use ones.

Regards,

	Shlomi Fish
-- 

---------------------------------------------------------------------
Shlomi Fish      shlomif-ik1l9ssToec+JF/[email protected]
Homepage:        http://www.shlomifish.org/

Knuth is not God! It took him two days to build the Roman Empire.