in reply to Read from a file and replace

You are changing the copy of the line in your program and then printing it to STDOUT (the screen). You would need to open a file for writing and write the lines you read in, and the ones you change to that new file.

Added code, and made some changes... The new file will be in newfile.html.

open(FH, "<file.html"); open(OUT, ">newfile.html"); my $line = ''; my $find = quotemeta("here.company.com/pagedir"); my $replace = "there.company.com/"; while($line = <FH>) { $string =~ s/$find/$replace/g; print OUT $string; } close(FH); close(OUT);
runrig's will work as well, and it significantly shorter.