in reply to Best way to validate a string as a color?
Hello pra,
Welcome to the Monastery. What about Term::ANSIColor/Function Interface/colorvalid, sample of code bellow:
#!/usr/bin/perl use strict; use warnings; use feature 'say'; use Term::ANSIColor qw(colorvalid); use Term::ANSIScreen qw/:color :constants/; my $valid = colorvalid ('magenta'); say "Color string is ", $valid ? "valid" : "invalid"; say MAGENTA . "Magenta" . RESET; __END__ $ perl test.pl Color string is valid Magenta
Hope this helps, BR.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Best way to validate a string as a color?
by choroba (Cardinal) on Oct 17, 2017 at 16:38 UTC | |
by Your Mother (Archbishop) on Oct 17, 2017 at 17:00 UTC | |
by LanX (Saint) on Oct 17, 2017 at 17:51 UTC | |
by pra (Initiate) on Oct 18, 2017 at 11:07 UTC | |
by Your Mother (Archbishop) on Oct 18, 2017 at 15:16 UTC | |
by pra (Initiate) on Oct 18, 2017 at 16:34 UTC |