while() { s!(.*?),(.*?)!$1A$2!g; s!(.*?),(.*?)!$1B$2!g; print; } __DATA__ This is to test. a, b a,b #### This is to test. a, b aBb