in reply to Substitute for variable-length look-behind?

Here's another solution, somewhat more elegant than my previous one.
s{<code>(.+?)</ code>|\[(.+?)\]|(<!--.+?-->)} {defined $1 ? "$GREEN$1$RESET" : defined $2 ? "$RED$2$RESET" : defined $3 ? "$YELLOW$3$RESET" : warn "Broken with $+\n" }ge;

The PerlMonk tr/// Advocate