Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Hex to array conversion

by ChOas (Curate)
on Oct 08, 2007 at 13:49 UTC ( #643460=note: print w/replies, xml ) Need Help??


in reply to Hex to array conversion

Works too:
my @rgb = map {hex($_) } unpack 'xa2a2a2', "#FF00FF"; print "(",join(',',@rgb),")\n";

GreetZ!,
    ChOas

print "profeth still\n" if /bird|devil/;

Replies are listed 'Best First'.
Re^2: Hex to array conversion
by bart (Canon) on Oct 08, 2007 at 14:32 UTC
    While we're busy doing silly pack/unpack strings:
    $str = '#FE00FD'; $str =~ tr/0-9a-fA-F//cd; # remove non-hex characters my @rgb = unpack 'C*', pack 'H*', $str; # pack hex as 3 bytes, unpack + into list of 3 character codes $" = ","; $\ = "\n"; print "(@rgb)";
    Result:
    (254,0,253)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://643460]
help
Chatterbox?
[Lady_Aleena]: shmem, sorry I was outside for a moment moving my car out of hubby's way.
[Lady_Aleena]: shmem, there is ONE song which throws a wrench in the works for both MP3::Info and MP3::Tag.
[shmem]: Lady_Aleena: fix it, or delete it ;-)
[Lady_Aleena]: shmem, I'm not sure how.
[shmem]: well, deleting is done with 'rm' :-P

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2017-04-23 22:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (432 votes). Check out past polls.