while () { while (s/(AAA\.\d)/xxxxx/) { push (@list, $1); } } #### while () { push (@foo, grep /AAA\.\d/, split(/\s*,\s*/)); }