Where does the function "remove" come from? It isn't a built-in function. Do you mean "unlink"?
The parameters for "rename"
should be the other way around and do not need quotes around them.
Why declare "our @data" and not "my @data"?
If the file is huge, the process will be slow since you're slurping the whole file in. It would be better to read and process line by line.
-imran