use IO::File;
use File::Find;

$ignore = "-gif-jpg-fig-ico-gz-mcp-xdc-opt-ucs2-ucs4-";
find(\&totxt, '.');

sub totxt {
        $oname = $_;
	$tname = '.#' . $_;
        if (!-f) {
            return;
        }
	@exts = split /\./;
        while ($#exts && ($ext = pop(@exts))) {
            if ($ignore =~ m|-$ext-|i) {
                return;
            }
	}
	$srcfl = new IO::File $oname, "r" || die;
	$dstfl = new IO::File $tname, "w" || die;
        binmode $srcfl;
        while (<$srcfl>) { 
            while (s/\r\n$/\n/) {
                ;
            }
	    print $dstfl $_; 
	}
	undef $srcfl;
	undef $dstfl;
	unlink $oname || die;
	rename $tname, $oname || die;
	print "Converted file " . $oname . " to text in " . $File::Find::dir . "\n"; 
}
