#!/usr/bin/perl
#
# straycats -- find catpages with no parent manpage source

for $root (split(/:/, shift || $ENV{'MANPATH'} || '/usr/man')) {
    chdir($root) || die "can't chdir to $root: $!\n";

    foreach $catdir ( <cat*> ) {
	opendir (catdir, $catdir) || (warn("can't opendir $catdir: $!"),next);
	($mandir = $catdir) =~ s/cat/man/;
	foreach $file ( readdir(catdir) ) {
	    next if $file eq '.';
	    next if $file eq '..';
	    next if -e "$mandir/$file";
	    print "no man page for $root/$catdir/$file\n";
	} 
    } 

}
