my $hhh = unpack('h*',pack('h*',"20") ^ pack('h*',"61")); #xor ' ' and 'a' should result in 'A' print unpack('h*',$hhh);