Lets learn about converting a character string into a HEX string. For example you have a string "abcd", it will convert it into HEX string as "61626364". Means just take each character from the string, and get its ascii code, and convert it into HEX.
I'm using regular expression (REGEX) to do this conversion. Below is the code.
## Initial string
$string = "abcdefjhijklmnopqrstuvwx";
## convert each character from the string into HEX code
$string =~ s/(.)/sprintf("%x",ord($1))/eg;
The above code will convert the provided string string into it's corresponding HEX code. Using regex i'm picking up the each character from the string, and get the ascii code using ord() function. Then using sprintf() I've just printed as HEX code.
If you want the output as UPPERCASE, you'll just need to make %x into %X inside your sprintf() function.
$string =~ s/(.)/sprintf("%X",ord($1))/eg;
The output will be as below for Lowercase, and Upper case:
The reverse one is at http://icfun.blogspot.com/2009/05/perl-convert-hex-string-into-character.html