in reply to greedy subexpression between two nongreedy ones

Just trying to see how many '?' I can get in one regex :)

s/,.*?(?:(cd).*?)??,/=$1=/

This will, of course, give "Use of uninitialized value $1 in concatenation (.)" if you use warnings. Here's a fix for that, if needed.

s;,.*?(?:(cd).*?)??,;=@{[$1 // '']}=;

or

s/,.*?(?:(cd).*?)??,/$1 ? "=$1=" : "=="/e # without that @{[]} trick