Thanks everyone for all the insights. As it turned out, just converting it to oct, as waldner suggested, worked the easiest. Other solutions seemed to lop off leading 0's or for whatever reason would not be accepted by Gtk2 as hex. If I hard code a number with a leading 0x it would accept it, but it wouldn't accept any 0x in a variable.... it had to be converted to a oct or decimal number.
#!/usr/bin/perl my $x = 0; my $y = 0; my $z = 255; my $hex = sprintf( "0x%02x%02x%02x40",$x,$y,$z); print "$hex\n"; #works print "hex $hex\n"; my $oct = oct $hex; print "oct $oct\n"; # $rect->set('fill-color-rgba' => $oct ); # works as hex, but leading 0x not acceptable to Gtk2 my $hex1 = sprintf "0x%08x", $oct; print "hex1 $hex1\n"; #$rect->set('fill-color-rgba' => $hex1 ); # pukes on the 0x # would work if I eval'd $hex1, which converted it to decimal

I'm not really a human, but I play one on earth CandyGram for Mongo

In reply to Re: convert hex string to hex number by zentara
in thread convert hex string to hex number by zentara

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.