in reply to regex to rename last _ with ,

Use () to catch the end portion: m{ _ ([^_]+) $ }x. Then use the portion captured in replacement via $1. And, RTFM.