#!/usr/bin/perl -w

use Win32::Clipboard;

my $clip = Win32::Clipboard::GetText;
my $dupes;

map {
	$_ = lc($_);
	if (exists $uniq{$_}) {
		warn "Duplicate removed: $_\n";
		$dupes++;
	}
	else {
		$uniq{$_}++;
	}
} split(/\s*[\r\n]+/, $clip);

Win32::Clipboard::Set( join("\r\n", sort keys %uniq) );


# And print out something useless to keep users happy
if ($dupes) {
	warn "Removed $dupes duplicates. ",
	scalar(keys %uniq), " unique values in clipboard.\n";
} else {
	warn "No duplicates found.\n";
}
