$infile = 'C:\russ\weights\preg.htm'; $outfile = 'C:\russ\weights\preg_clean.htm'; # No, I am not pregnant, but I am helping a pregnant woman out! No...not just helping her get # her start either :) $orgtext = Whey; $newtext = Popcorn; undef $/; #slurp mode, read files in a whole open IN, $infile or die $!; $intext = ; close IN; $intext =~ s/$orgtext/$newtext/ms; # the ms is for coping correctly with newlines (that can easily appear in a binary). open OUT, ">$outfile" or die $!; print OUT $intext; close OUT; # replaces ALL occurrences of orgtext with newtext and places the number of occurences in $count