Is there a way to get the regex to fail in the cases where true is not printed? #### (?{ code }) ... This zero-width assertion evaluates any embedded Perl code. It always succeeds, and its code is not interpolated.