Just a suggestion on the goal: you probably don't want to modify the file on disk anyway. You really want to pastebin the config file anyway, so I would suggest the following design:
- Slurp in the file given on the commandline (just one per execution).
- Modify it with your regexes.
- Using WWW::Mechanize, paste it to your favourite pastebin site. Use the return page to determine the URL it's now sitting at.
- Print the URL (for copy-and-paste), and, if you can, put it in the clipboard (how to do that depends on your OS - for Unix, I'd just open a pipe to xclip and let that do my work for me)
This not only makes it safer (by not overwriting your real config files by accident), but also far more convenient. And there's lots to learn about perl in there, too :-)