in reply to Converting FILEHANDLE to string

Check CPAN for modules. File::Slurp does this sort of thing, and has just been modified to extend its functions.
use File::Slurp; my $string = read_file("yourfile"); write_file("yourfile.bak", $string); $string =~ s/everything/otherthings/g; $string .= "endbit\n"; write_file("newfile", $string);
This has problems if your file/string is huge. There is also a Tie::Slurp module or somesuch but I admit I haven't had it working yet.