This example shows how to print some colours with Perl.
1 2 3 4 5 6 7 8 9 |
print "e[37m whiten"; print "e[33m yellown"; print "e[36m cyann"; print "e[34m bluen"; print "e[32m greenn"; print "e[35m majentan"; print "e[31m redn"; print "e[30m blackn"; print "e[37m back to whiten"; |
The result looks like this:
On some Terminal it don’t work, so another solution is to use the Module Term::ANSIColor:
1 2 3 4 5 6 7 8 9 10 |
#!/usr/bin/perl use strict; use Term::ANSIColor; my @color = qw(black red green yellow blue magenta cyan white); for my $col (@color){ print color($col),$col, color($col),"\n"; } print "default\n" |
Result is now: