my $index = $#array; #Doesn't treat array as comment my $txt = "$index and something"; #Highlights $index! print OUT "$txt->test()"; #Doesn't highlight ->test() s/ (\d+ #test \w{1,3}) (\s) / $2 ? "yes" : $1 /ex; #Recognizes s///ex as the regex