Some quick comments ..
- In the UNIX/Linux world that Perl mostly lives in, it is more likely that the file name you'll be working on will be passed in as an argument, rather than supplied interactively, in response to a prompt. This allows us to do clever things like find the files we want to work on (perhaps by using ls and xargs and then call your utility.
- Figure out a plan for what your file names are going to be. Typically you would do something like this: original file is renamed by adding '.org' or '.orig' to it (for original), and a new file is created with the original file name. Alternatively, '.org' can be '.bak' (for backup).
- You asked Would I have to do the above line for all possible tags or is there an easier way, and the answer is, yes, use one of the modules suggested to you already. Parsing HTML with a regular expression is a tempting challenge, but it's a fool's errand. That means don't try to do it unless you want a Greek chorus chanting "Don't do that!" when you come and ask for assistance.
- There's no rename command in UNIX/Linux -- we use mv (move) instead, and if you're going to be copying, moving or renaming files, best use File::Copy instead, for the following reasons:
- It's tried and true code.
- It works on multiple platforms.
- it will handle all of the weird cases that you never thought of but will wake you at 4am if your homebrew code gets installed on a Production machine and it breaks in the worst possible way.
- You won't have a Greek chorus chanting "Use CPAN" all the time. Actually, File::Copy is a core module, so you don't even have to go to CPAN for it.
There's a lot to learn, so search for articles here on Perlmonks and do lots of reading. 99% of the time, the thing you want to do has already been thought of and coded up. It's amusing to reinvent the wheel, but only do so if you have plenty of time to learn.
Alex / talexb / Toronto
"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds