in reply to editing a file

The perlrun manpage has some switches which will let you do "in-place" file edits, something like this:
#!/usr/bin/perl -pi.orig if(should_change($_)){ $_ = change_line($_); }