in reply to Editing Contents of a File

The simplest way is a one-liner:

perl -i.bak -pe 's/hello/goodbye/gi' file1 file2 ...
You are reading the file and modifying an in-memory string, but not attempting to write that string back out. I would do this:
use Fcntl qw(:seek); open (FOO, "+<$foo") or die "Can't open $foo: $!"; my $slurp = join '', <FOO>; $slurp =~ s/hello/goodbye/sgi; seek FOO, 0, SEEK_SET; print FOO $slurp; truncate FOO, tell FOO; close FOO;
Update: Added the truncate call for cases where the modified file contents are shorter than the original. Oops.