It's down to the version of Term::ANSIColor.
I had Strawberry 5.30.0.1's default Term::ANSIColor v4.06, and it gave me the same error Discipulus saw.
I tried
@echo =================== 8 v 16
perl -E "use Term::ANSIColor; say my $x=colored('red text', 'red on_wh
+ite'); use Data::Dump; dd $x"
perl -E "use Term::ANSIColor; say my $x=colored('red text', 'bright_re
+d on_white'); use Data::Dump; dd $x"
perl -E "use Term::ANSIColor; use Data::Dump; my $x = colored('black o
+n white', 'black on_white'); say $x; dd $x"
@echo =================== 256 vs 8 or 16
perl -E "use Term::ANSIColor; use Data::Dump; my $x = colored('black o
+n white', 'rgb000 on_white'); say $x; dd $x"
@echo =================== [id://11146167]
perl -E "use Term::ANSIColor; use Data::Dump; my $x = colored('black o
+n white', 'r0g0b0 on_white'); say $x; dd $x"
perl -E "say qq(\e[38;5;16;47mblack on white\e[0m)"
perl -E "say qq(\e[38;2;0;0;0;47mblack on white\e[0m)"
perl -E "say qq(\e[38;2;255;0;0;47mred on white\e[0m)"
perl -E "say qq(\e[38;2;0;127;0;47mgreen on white\e[0m)"
perl -E "say qq(\e[38;2;0;0;255;47mblue on white\e[0m)"
perl -E "say qq(\e[38;2;191;127;191;47mpurple on white\e[0m)"
perl -E "use Term::ANSIColor; use Config; say for $Term::ANSIColor::VE
+RSION, $], $Config{myuname};"
... And everything but the r0g0b0 worked†; the r0g0b0 gave
Invalid attribute name r0g0b0 at -e line 1.
I then realized that since kcott was using v5.36, there was probably a newer Term::ANSIColor , so then I ran cpanm Term::ANSIColor, which installed 5.01. When I ran my same batch script with the updated module, it worked without the error.
So Discipulus, you need to update Term::ANSIColor. Per their change list, rNNNgNNNbNNN notation was added in 5.00.
(To get the colors to work, I did use the VirtualTerminalLevel = 1 that the AM recommended)
edit: †: with full 24 bit color working fine for the red, green, blue, and purple, using manual escape sequences.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.