my ($b,$g,$r) = sprintf('%06x', $color) =~ /(..)/g; #### my $hexrgb = join '', reverse sprintf('%06x', $color) =~ /(..)/g;