I see three problems.
The first is that the -p option reads your input line by line. It presents each line to your substitution statement, which is not what you want. I think you'll probably have to suck it up and write a real-live Perl script. This script will read the whole file, do the substitution, and write the file out again. (I'm thinking you'll want to do just one substitution per file, but in case you anticipate more than one occurrence of the search string and want to replace them all, don't forget the g switch at the end of the substitution statement.)
It's not difficult to read the whole file in one fell swoop:
Code:
open(INPUT,"<$ARGV[0]") or die;
@input_array=<INPUT>;
close(INPUT);
$input_scalar=join("",@input_array);
# Do your substitution here.
open(OUTPUT,">$ARGV[0]") or die;
print(OUTPUT $input_scalar);
close(OUTPUT);
The second problem is that this won't quite work, because searching ordinarily doesn't do multi-line matching. To fix that, use the * special variable, like this:
Code:
$*=1;
open(INPUT,"<$ARGV[0]") or die;
@input_array=<INPUT>;
close(INPUT);
$input_scalar=join("",@input_array);
# Do your substitution here.
open(OUTPUT,">$ARGV[0]") or die;
print(OUTPUT $input_scalar);
close(OUTPUT);
The third problem is that even this won't work completely, because you want the "." in your search string to match every character; unfortunately, it only matches every character except \n. So in your search string, instead of saying
say
Hope this helps.