CMD-Colors
view release on metacpan or search on metacpan
example/ConsoleColors.pl view on Meta::CPAN
#!/usr/bin/perl
use strict;
use CMD::Colors;
## Example Usage
Cprint('hello, This is RED text', 'red');
Cprint("\nhello, This is RED text with WHITE background", 'red', 'white');
Cprint("\nhello, This is RED (Bold) text", 'red', undef, 'bold');
Cprint("\n");
exit;
## Demo ##
foreach my $color (keys %{$COLOR_CODES{'foreground'}}) {
Cprint("This is $color text", $color);
print "\n";
foreach my $bgcolor(keys %{$COLOR_CODES{'background'}}) {
Cprint("This is $color text with $bgcolor background", $color, $bgcolor);
print "\n";
lib/CMD/Colors.pm view on Meta::CPAN
##### Example Usage #####
## Prints text with 'RED' color & default background
Cprint('hello, This is RED text', 'red');
## Prints text with 'RED' color & 'white' background
Cprint('hello, This is RED text', 'red', 'white');
## Prints text with 'RED' color & 'default' background & BOLD text
Cprint('hello, This is RED text', 'red', 'default', 'bold');
## Prints text with 'RED' color & 'default' background & 'half_bright' text
Cprint('hello, This is RED text', 'red', undef, 'half_bright');
##### Show all available 'foreground' & 'background' colors - DEMO #####
foreach my $color (keys %{$COLOR_CODES{'foreground'}}) {
Cprint("This is $color text", $color);
print "\n";
foreach my $bgcolor(keys %{$COLOR_CODES{'background'}}) {
lib/CMD/Colors.pm view on Meta::CPAN
Syntax -
Cprint("TEXT TO BE Printed", "ForegroundCOLORName", "BackgroundColorName", "TEXT Property");
Supported Colors ::
Foreground - black, red, green, brown, blue, magenta, cyan, white
Background - black, red, green, brown, blue, magenta, cyan, white
Supported Properties ::
'bold' ## Set bold
'half_bright' ## Set half-bright (simulated with color on a color display)
'underscore' ## Set underscore (simulated with color on a color display)
## (the colors used to simulate dim or underline are set
'blink' ## Set blink
'reverse_video' ## Set reverse video
'reset_mapping' ## Reset selected mapping, display control flag, and toggle
## meta flag (ECMA-48 says "primary font").
'null_mapping' ## Select null mapping, set display control flag, reset
## toggle meta flag (ECMA-48 says "first alternate font").
'null-mapping ' ## Select null mapping, set display control flag, set toggle
lib/CMD/Colors.pm view on Meta::CPAN
'red' => 41, ## Set red background
'green' => 42, ## Set green background
'brown' => 43, ## Set brown background
'blue' => 44, ## Set blue background
'magenta' => 45, ## Set magenta background
'cyan' => 46, ## Set cyan background
'white' => 47, ## Set white background
'default' => 49, ## Set default background color
},
'other' => {
'bold' => ';1', ## Set bold
'half_bright' => ';2', ## Set half-bright (simulated with color on a color display)
'underscore' => ';4', ## Set underscore (simulated with color on a color display)
## (the colors used to simulate dim or underline are set
'blink' => ';5', ## Set blink
'reverse_video' => ';7', ## Set reverse video
'reset_mapping' => ';10', ## Reset selected mapping, display control flag, and toggle
## meta flag (ECMA-48 says "primary font").
'null_mapping' => ';11', ## Select null mapping, set display control flag, reset
## toggle meta flag (ECMA-48 says "first alternate font").
'null-mapping ' => ';12', ## Select null mapping, set display control flag, set toggle
( run in 1.560 second using v1.01-cache-2.11-cpan-5dc5da66d9d )