#!/usr/bin/perl use warnings; use strict; use File::Copy; my($fileName) = $ARGV[0]; print("$fileName \n"); my($find) = "cps***"; my($replace) = "nat***"; if(-e $ARGV[0]) { my($copy) = "$ARGV[0].bak"; copy($ARGV[0], $copy) or die "File cannot be copied. \n"; } else { print "File does not exist. \n"; exit; } open(INPUT,"$copy") or die 'Cannot open file: $!\n'; open(OUTPUT,">$ARGV[0]"); while(){ $_ =~ s/$find/$replace/g; print OUTPUT $_; } close INPUT; close OUTPUT; unlink($copy); print("File $fileName correctly pointed\n"); exit 0;