in reply to How to convert the domain name format data into hexadecimal format?

I don't know what you're doing wrong, but it works fine for me without any magic.

I started wireshark, then typed perl -wle 'gethostbyname("www.google.com")', and wireshark showed me, among other stuff, a line with the protocol set to DNS, and the text Standard query A www.google.com in the Info field.

So I suspect that your problem is somewhere else.