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

kiat has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

Is it possible to have a ternary expression within the replacement bit of the regular expression? I've the following code and I'm trying to fix the size of font (captured in $1) if it's greater than 5:

$message =~ s~\[size=(.+?)\](.+?)\[/size\]~'<font size="' . $1 . '">' + . "$2</font>"~eisg; # I'm trying to test $1 so that if it's greater than 5, # fix it at 5, else leave it unchanged.
Thanks in advance :)