#!/usr/local/bin/perl

@lines = <STDIN>;
chop (@lines);
$longlongline = join(" ", @lines);
@words = split(/ /, $longlongline);
@words = reverse sort (@words);
$index = 0;
print("Words sorted in reverse order:\n");
while ($index < @words) {
        # note that the first time through, the following
        # comparison references $words[-1]. This is all
        # right, as $words[-1] is replaced by the null
        # string, and we want the first word to be printed
        if ($words[$index] ne $words[$index-1]) {
                print ("$words[$index]\n");
        }
        $index++;
}
