#ex_10-2
#Learning Perl, Appendix A, Exercise 10.2
print "Input file name: ";
chop($infilename = <STDIN>);
print "Output file name: ";
chop($outfilename = <STDIN>);
print "Search string: ";
chop($search = <STDIN>);
print "Replacement string: ";
chop($replace = <STDIN>);
open(IN,$infilename) ||
		die "cannot open $infilename for reading";
## optional test for overwrite...
die "will not overwrite $outfilename" if -e $outfilename;
open(OUT,">$outfilename") || die "cannot create $outfilename";
while (<IN>) { # read a line from file $a into $_
		s/$search/$replace/g; # change the lines
		print OUT $_; # print that line to file $b
}
close(IN);
close(OUT);

