http://www.perlmonks.org?node_id=494495


in reply to Ternary inside a regex

You can do that using the /e modifier:
$a = "size=1111"; $a =~ s/(\d+)/($1 > 5) ? 5 : $1/e; print $a, "\n"


Igor S. Lopes - izut
surrender to perl. your code, your rules.