my $re = $left ? qr/ab(..)ef/ : qr/gh(..)jk/; /$re/ or die("Bad data"); print "Caught $1\n"