Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re^5: 'rgb_palette' - Term::ANSIColor Helper -- errors on strawberry

by kcott (Archbishop)
on Aug 18, 2022 at 00:34 UTC ( #11146209=note: print w/replies, xml ) Need Help??

in reply to Re^4: 'rgb_palette' - Term::ANSIColor Helper -- errors on strawberry
in thread 'rgb_palette' - Term::ANSIColor Helper

++ Thanks for the bug report.

I found an existing bug report, #118255, which refers to a problem when -echo is used with prompt. It looks like -return, as I've used, has the same issue.

I've changed

$rgb = prompt 'Convert hex to decimal rgb (or just hit "Enter" to +quit): ', -return => '';


$rgb = prompt 'Convert hex to decimal rgb (or just hit "Enter" to +quit): ', -return => ''; # Fix for MSWin -- see +?id=118255 $rgb =~ s/\R\z//;

The s/\R\z// is a little more generic than s/[\r]*$//; but otherwise it's pretty much the same as your fix.

I've tested it on my machine (Cygwin) and it hasn't changed the functionality for me. Could you test that for me on your MSWin machine? Assuming it works OK, I'll update the code in the OP. Thanks.

— Ken

Replies are listed 'Best First'.
Re^6: 'rgb_palette' - Term::ANSIColor Helper -- errors on strawberry
by Discipulus (Canon) on Aug 18, 2022 at 07:51 UTC

    yes it works nice for me: the following version is also agnostic about the perl version:


    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

      Firstly, I'm glad this finally worked for you.

      "the following version is also agnostic about the perl version"

      Leaving out a "use VERSION;" statement does not achieve this; nor does adding a "use feature LIST;" statement.

      Your code will have problems with older Perl versions. Here's a non-exhaustive list:

      • Subroutine signatures were introduced in v5.20.0 (see "perl5200delta: Experimental Subroutine signatures"). I added information in the OP on how to deal with this.
      • I didn't really expect anyone to wind back v5.36 to a pre-5.10 version, so I made no comment about that in the OP; however, say() was introduced in v5.10.0 (see "perl5100delta: say()").
      • And for the same reason as the above point, I didn't mention that IO::Prompter requires v5.10.0 (see the first line of its source).
      • And, in the later fix for the MSWin bug, \R requires v5.10.0 (see "perlrebackslash: \R").

      — Ken

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11146209]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (2)
As of 2023-09-21 21:54 GMT
Find Nodes?
    Voting Booth?

    No recent polls found