The program below works as intended.  It recursively searches
directories and changes any instances of "spike.domain" to
"spike.lib.domain" without making a backup (I will already have the
directory backed up).  There are two things I would like to have the
program do that I'm having trouble with.  

1) I would like to make it skip processing itself.
2) I would like it to print out the name of changed files.  

Two of my best attempts to make the modifications:

1) Changing the "if" statement to "if ((-f) && (! $0))"  
   To me that says, "if it is a file and not program name."
   Trouble is when I run it no substitutions are made in the file.
   No errors reported either.

2) I have added, just outside the loop -
   print "Changed: $File::Find::name";
   This reports all files as having been changed instead of just files
   changed.
   
Any help appreciated:)

#!/usr/bin/perl -i
use strict;
use warnings;
use File::Find;

my $dir = ".";

find(\&edit_files, $dir);
sub edit_files {
    if (-f) {
        my $file = $_;
        local @ARGV = ($file);
        while(<>) {
            s/spike\.domain/spike\.lib\.domain/;
            print;
        }
    }
}


-- 
To know the truth is to distort the Universe.
                      Alfred N. Whitehead (adaptation)

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to