search/replace and update the file in perl script

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

I need a perl script to search and replace the keywords in a file, and
update that file with new

The usage should be perl oldvalue newvalue filename

I wrote the script, I can search and replace, but I guess
the problem is I don't know how to update the file.

$oldValue = $ARGV[0];
$newValue = $ARGV[1];
$fileName = $ARGV[2];

open(FILE, $fileName) or die("Unable to open file");

# read file into an array
@data = <FILE>;

foreach $line (@data)
{ print $line;
$line =~ s/$oldValue/$newValue/

Please advise. Thanks!!

Site Timeline