Last active
August 29, 2015 13:57
-
-
Save skaji/9728280 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use utf8; | |
{ | |
no strict 'refs'; | |
my @color = qw(black red green yellow blue magenta cyan white); | |
for (0..$#color) { | |
my ($c, $n) = ($color[$_], 30 + $_); | |
*$c = sub { -t *STDOUT ? "\e[1;${n}m@_\e[m" : "@_" }; | |
} | |
} | |
print black("black"), "\n"; | |
print green("success"), "\n"; | |
print red("error"), "\n"; | |
print yellow("yellow"), "\n"; | |
print blue("blue"), "\n"; | |
print magenta("magenta"), "\n"; | |
print cyan("cyan"), "\n"; | |
print white("white"), "\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use utf8; | |
use constant INTERACTIVE => -t *STDOUT; | |
sub green { INTERACTIVE ? "\e[1;32m@_\e[m" : "@_" } | |
sub red { INTERACTIVE ? "\e[1;31m@_\e[m" : "@_" } | |
sub white { INTERACTIVE ? "\e[1;37m@_\e[m" : "@_" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use utf8; | |
sub red { -t *STDOUT ? "\e[1;31m@_\e[m" : "@_" } | |
sub green { -t *STDOUT ? "\e[1;32m@_\e[m" : "@_" } | |
sub white { -t *STDOUT ? "\e[1;37m@_\e[m" : "@_" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment