in reply to convert hex string to hex 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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: convert hex string to hex number
by tobyink (Canon) on Jan 04, 2012 at 14:41 UTC |