# there may be some others but these are the ones I know of if($ENV{TERM} =~ /linux|xterm|xterm-color|vt220|ansi/) { $color = 1; } # assuming $char is the character you are about to print $char = "\33[0;32m$char\33[0m" if $color;