http://www.perlmonks.org?node_id=94143

Hi Mighty Monks,

A few months ago, I had to deal with GD. Most GD functions expect the colours to be given as lists of three figures (amounts of red, green and blue, in that order, as I'm sure you had already guessed). I for one preferred to store my colours as numbers in a hash, using the handy 0xnnnnnn notation. I thus needed a function that would take an integer as argument and return the three elements: a good opportunity for a bit of golfing (and obfuscation if you care to...).

The function assumes the arguments is a valid hexa triplet, i.e. an integer between 0 and 0xFFFFFF.

My entry (43 chars only counting within the braces):

sub hexa_triplet { map eval"0x$_",sprintf('%06x',pop)=~/(..)/g }

--bwana147