while (<>) { # replace italics and bold s{^([ib])\s+(.*)}[<$1>$2$1>]; # find ordered lists if (my $hit= /^\[\s*$/ .. /^\]\s*$/) { if ($hit==1) { print "