$_ = "it's 94% fat-free!"; # a string that should match # the following code works but the logic is outside the RE print "match\n" if (/(\d{1,3})%/, $1>91); # the following code also works but is offensive print "match\n" if /(\d{1,3})%(?(?{$1>91})(?:.*)|(?!.*))/; #### /(\d{1,3})% # find a percentage to match (?( # begin conditional construct ?{$1>91}) # return value of a code block can be used to test (?:.*) # RE to use if true -- this always-true RE makes entire RE match | (?!.*))/ # RE to use if false -- this always-false RE makes entire RE fail