#!/usr/bin/env perl
# dups -- find duplicate adjacent words
use strict;
my $red = "\033[0;31m";
my $reset = "\033[0m";
my $count = 0;
my $lastword = "";
while (<>) {
    chomp;
    my @words = split /\s+/;
    foreach my $word (@words) {
        my $lc = lc($word);
        $lc =~ s/[^a-z]//g;
        if ($lc eq $lastword && $lc ne "") {
            print "$ARGV:$.: ${red}$word${reset}\n";
            $count++;
        }
        $lastword = $lc;
    }
}
exit ($count > 0 ? 1 : 0);
