Skip Menu |
 

This queue is for tickets about the Term-ANSIColor CPAN distribution.

Report information
The Basics
Id: 131414
Status: resolved
Priority: 0/
Queue: Term-ANSIColor

People
Owner: RRA [...] cpan.org
Requestors: joeinwap [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 5.01



Subject: Example for uncolor() does not work as documented.
Date: Fri, 10 Jan 2020 00:16:42 -0800
To: bug-Term-ANSIColor [...] rt.cpan.org
From: Joe Smith <joeinwap [...] gmail.com>
Download (untitled) / with headers
text/plain 556b
This example does not work: # Map escape sequences back to color names. use Term::ANSIColor 1.04 qw(uncolor); my $names = uncolor('01;31'); print join(q{ }, @{$names}), "\n"; In scalar context, uncolor() returns the list size instead of an array reference. Adding "use strict;" the error is "cannot use string '2' as an array reference". The function works as expected when using @names instead. Reference: Term::ANSIColor 5.00 released https://www.nntp.perl.org/group/perl.perl5.porters/2020/01/msg256833.html
Subject: Re: [rt.cpan.org #131414] Example for uncolor() does not work as documented.
Date: Fri, 10 Jan 2020 10:24:08 -0800
To: "Joe Smith via RT" <bug-Term-ANSIColor [...] rt.cpan.org>
From: Russ Allbery <rra [...] cpan.org>
Download (untitled) / with headers
text/plain 932b
"Joe Smith via RT" <bug-Term-ANSIColor@rt.cpan.org> writes: Show quoted text
> This example does not work:
Show quoted text
> # Map escape sequences back to color names. > use Term::ANSIColor 1.04 qw(uncolor); > my $names = uncolor('01;31'); > print join(q{ }, @{$names}), "\n";
Oh! Doh. I see. Right, uncolor just returns a list, not a reference to an array. The function documentation is correct but the example is wrong. I'll fix this in the next release, and I think I'll make it return the colors as a string in a scalar context since that seems more useful. Thank you for the report and for pointing out what I was confused about! -- #!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker $^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD, 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{ rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
Download (untitled) / with headers
text/plain 261b
I thought about this some more and realized that if I changed the behavior in a scalar context, it might break backward compatibility, so I just fixed the example to match the code and documentation. This fix is now released in 5.01. Thank you for the report!


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.