in reply to change/detect term screen background color

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), $_); } }

Replies are listed 'Best First'.
Re^2: change/detect term screen background color
by Allasso (Monk) on Feb 19, 2011 at 19:51 UTC

    Your first script didn't work for me, it only changes the bg of the text.

    also, there is an error in your code:
    system("echo -e"\e[1;32;40m black"); system("echo -e "\e[0m");

    should be something like:

    system("echo -e '\e[1;32;40m black'"); system("echo -e '\e[0m'");

      okay, it works if I add this after the color change:

      system("clear");

        here is an example that works:

        change screen color for a script, then change it back when script exits:

        #!/usr/bin/perl use strict; use warnings; # change bgcolor and text system("echo -e '\e[44m'"); system("clear"); print "interactive script with blue background...\n\n"; print "press return to exit script:\n\n"; <STDIN>; # revert to original color system("echo -e '\e[0m'"); system("clear");
        Anyway, thanks for getting my brain going.
Re^2: change/detect term screen background color
by Anonymous Monk on Feb 20, 2011 at 14:18 UTC
    Here's a script that changes the bgcolor(fullscreen) to black and text color to bold green
    It does no such thing. This code (your posted code):
    #!/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");
    doesn't even compile

    When posting untested code, please mark it as such.

    When posting tested code, please post the code that you actually ran.

    Shame on you. You should know better.