I don't know of any module that can simply and quickly change
color. I usually just do a system call. That is the crux of the problem. There's so many different systems, consoles, terms, and whatever that it's a real pain to try and find a general way to do it. Here's a script that changes the bgcolor(fullscreen) to black and text color to bold green:
#!/usr/bin/perl
use strict;
use warnings;
# change bgcolor and text
system("echo -e"\e[1;32;40m black");
sleep 5;
# revert to original color
system("echo -e "\e[0m");
Here's a script that I use to get info about my terminal
colors and capabilites:
#!/usr/bin/perl
use strict;
use warnings;
use Term::Cap;
use Term::ExtendedColor qw(fg get_colors lookup);
use Data::Dumper::Concise;
my $termcap = Term::Cap->Tgetent({ Term => 'undef' });
print "Capabilities found: ", join(', ', sort(keys %{$termcap})), "\n"
+;
print Dumper(my $colors = get_colors());
for(0 .. 255) {
my $color_str = lookup($_);
if(defined($color_str)) {
printf("%25s => %s\n", fg($color_str, $color_str), $_);
}
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.