in reply to conditional statement in substitution expression
This incurs the performance penalty for using $&, so you might prefers/\*\*([^\*]+)\*\*\s\,\s\*\*([^\*]+)\*\*(\s\,)?/(grep {index($_,'_') +>=0} $1,$2)?"**$1_($2)**":$&/ge;
while(<DATA>) { s/(\*\*([^\*]+)\*\*\s\,\s\*\*([^\*]+)\*\*(\s\,)?)/(grep {index($_,'_ +')>=0} $2,$3)?"**$2_($3)**":$1/ge; print; }
Caution: Contents may have been coded under pressure.
In Section
Seekers of Perl Wisdom