$a = ("ac" =~ /a(b)c/) ? $1 : 'd'; print $a;