Sorry, I should have mentioned this. But, actually I'm new to perl. I thought of asking you guys to have some kind of knowledge and then kind of start learning from there.
Comment on Re^2: remove entries with duplicate characters
How new? :-) If you have not yet, set aside an afternoon and go through perlintro. There's a section there for virtually each piece of what you need to do in your program. Start with some simple exercises, loops, etc. Don't try to pull off your goal in the first step. See my follow up to the code you showed here.
The way forward always starts with a minimal test.