Terminal control/Coloured text: Difference between revisions

Added Perl example
(Added Perl example)
Line 895:
 
<lang parigp>for(b=40, 47, for(c=30, 37, printf("\e[%d;%d;1mRosetta Code\e[0m\n", c, b)))</lang>
 
=={{header|Perl}}==
<lang perl>my %colors = (
red => "\e[1;31m",
green => "\e[1;32m",
yellow => "\e[1;33m",
blue => "\e[1;34m",
magenta => "\e[1;35m",
cyan => "\e[1;36m"
);
$clr = "\e[0m";
 
print "$colors{$_}$_ text $clr\n" for sort keys %colors;
 
# the Perl 6 code also works
use feature 'say';
use Term::ANSIColor;
 
say colored('RED ON WHITE', 'bold red on_white');
say colored('GREEN', 'bold green');
say colored('BLUE ON YELLOW', 'bold blue on_yellow');
say colored('MAGENTA', 'bold magenta');
say colored('CYAN ON RED', 'bold cyan on_red');
say colored('YELLOW', 'bold yellow');</lang>
 
=={{header|Perl 6}}==
2,392

edits