#!/usr/local/bin/perl

require 'find.pl';

$^I = ".bak";            
                               
sub process
{
 my $changes = 0;
 @ARGV = @_;
 die if (@ARGV != 1);
 local ($_);            
 while (<>)
  {
   print STDERR "process $ARGV\n" if ($. == 1);
   $changes++ while (s/\bnTk\b/Tk/);
   warn "$ARGV:$.:$_" if (/nTk/);
   print;
   if (eof)
    {
     print STDERR "$changes changes in $ARGV\n";
     $changes = 0;
     $. = 0;
    }
  }
}

sub wanted
{
 if (!-l $_ && -T $_ && !/\.bak$/)
  {
   process($_);
  }
}

@ARGV = './' unless (@ARGV);

@files = @ARGV;

foreach $arg (@files)
 {
  if (-d $arg)
   {
    find($arg);
   }
  elsif (!-l $arg && -T $arg)
   {
    process($arg);
   }
 }


