Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

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";


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)";

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://643460]
[Corion]: Oof - "Anyway, if it is not obvious, please keep this discussion entirely confidential for now.", as seen on a public mailing list ;)
[Discipulus]: uh no choroba.. i do not practice much with online putyour image sites:can you suggest one (that possibly remove the pic after few days)?
[choroba]: Corion a bug report?
[choroba]: I have no idea :-( I used to post to, but they don't seem to feature "private" pictures in the free version now
[Discipulus]: dazz i'm not an experts but i think it would be possible
[Corion]: dazz: I think Image::Magick can "read" from an in-memory filehandle
[Corion]: choroba: No, some general admin discussion of how to handle (company) user accounts
[Discipulus]: might be it is necessary to pass the pic data like MIME::Base64:: encode( data..

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (10)
As of 2017-03-27 07:53 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (317 votes). Check out past polls.