I read the post How to convert a hexadecimal number to a char string in Perl to convert a hexadecimal number to a character string.
How can I do the reverse operation? I need convert a character string to hexadecimal in Perl. For example, I have a string, "hello world!" (should be "Hello, World!"), and I must get:
00680065006C006C006F00200077006F0072006C00640021
Here's another approach. Do it all in one go with a regex.
my $string = 'hello world!';
$string =~ s/(.)/sprintf '%04x', ord $1/seg;