#! /usr/local/bin/perl5 $search_for = 'foo'; $replace_with = 'bar'; foreach $filename (@ARGV) { open(FILE, "$filename"); @data = <FILE>; close(FILE); for($i = 0; $i < @data; $i++){ @data[$i] =~ s/$search_for/$replace_with/g; } open(FILE, ">$filename"); print FILE (@data); close(FILE); }
In reply to Re: search-and-replace in files
by freddo411
in thread search-and-replace in files
by vxp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |