いや、これだろ
$pat = qr/(??{$condition ? 'foo' : 'bar'})/;