sub print_debug { # black red green yellow blue magenta cyan white my ($text, $color) = @_; unless ($color) { print STDERR "$text \n"; } else { use Term::ANSIColor qw(:constants); if ($color =~ /blue/i) { print STDERR BLUE, "$text \n", RESET; } elsif ($color =~ /yellow/i) { print STDERR YELLOW, "$text \n", RESET; } elsif ($color =~ /red/i) { print STDERR RED, "$text \n", RESET; } elsif ($color =~ /blue/i) { print STDERR BLUE, "$text \n", RESET; } elsif ($color =~ /magenta/i) { print STDERR MAGENTA, "$text \n", RESET; } elsif ($color =~ /cyan/i) { print STDERR CYAN ON_GREEN, "$text \n", RESET; } } }