in reply to editing a file

I think the best answer to your question can be found here: perl -i
hope it helps!

-malloc