Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Hex to array conversion

by gam3 (Curate)
on Oct 08, 2007 at 14:32 UTC ( [id://643470]=note: print w/replies, xml ) Need Help??


in reply to Hex to array conversion

similar to the unpack example, but with error checking.
use strict; sub hex2rgb { my $hex = shift; if (my @data = ($hex =~ /\#((?:[0-9a-fA-F]){2})((?:[0-9a-fA-F]){2} +)((?:[0-9a-fA-F]){2})/)) { return join(',', map({ hex($_); } @data)); } else { die "Bad hex: ", $hex; } } print hex2rgb("#ff00ff"), "\n"; print hex2rgb("#fx00ff"), "\n";
-- gam3
A picture is worth a thousand words, but takes 200K.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-04-23 18:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found