in reply to Read from a file and replace

See perldoc perlrun and the -i operator (along with -p and -n (-p in your case)).
perl -pi.bak -e 's#\Qhere.company.com/pagedir#there.company.com/#g' fi +le1 file2 etc...
Otherwise you are going to have to open a new output file, print to it, then rename the new file to the old file name, which is what the -i switch implicitly does.