Your pseudo-coded problem statement makes very little sense.
- read perldoc perlretut or any number of other documents re regexen.
- Change the capturing parens and perhaps add /g.
- Come back and show us what you've tried along with an explanation of how it fails, if that's the case