1
2
3
4
5
6
7
8
my $hex = 'E1B4FF';
my $evalcode = '$hex = 0x'.$hex;
eval $evalcode;
#print $hex . "\n";#14791935
my $x1 = (($hex >> 16) & 0xFF);
my $x2 = (($hex >> 8) & 0xFF);
my $x3 = ($hex & 0xFF);
print $x1 . $x2 . $x3 . "\n";
1 2 3
my $hex = 'E1B4FF'; my ($x1,$x2,$x3)=unpack('C3', pack( 'H6', $hex ) ); print $x1 . $x2 . $x3 . "\n";
1 2 3
my $hex = 'E1B4FF'; my ($x1,$x2,$x3)=map{ hex }unpack('(A2)*',$hex ); print $x1 . $x2 . $x3 . "\n";
1 2 3
my $hex = 'E1B4FF'; my ($x1,$x2,$x3)=map{ hex }( $hex=~/(..)/g ); print $x1 . $x2 . $x3 . "\n";