I read this post: How to convert hex to char string in perl to convert hex to chart string.
How can I do reverse operation? I need convert char string to hex in perl. For example, I have string "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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With