ktb wrote:
> 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.
        But while you are running the script $0 will always be true.  Also
from my testing the name in $0 shows the full pathname while what comes out
of File::Find is in reference to where you started the processing. So you
might need to do something like this:
        #
        # Start of the program
        #
        my $MyScript = $0;
        $MyScript =~ s/.+\//;
        if ( (-f) && ( ! /$MyScript/ ) )
> 
> 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.
        I would add a variable just before the while ( my $MyProc = 0 ) and
change the line inside the while to be like

        $MyProcFlag++ if ( s/spike\.domain/spike\.lib\.domain/ );

And right after the while something like (gives you the number of changes
made : from your commments that it does work, this assumes only one change
per line):

printf "%-s:(%4d)\n", $file, $MyProcFlag if ( $MyProcFlag );

Wags ;)


**********************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
****************************************************************


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

Reply via email to