Can someone tell me how binmode in Perl can be used to achieve the same function as following one-liner, so as to print out the hex data of one text ?
$ perl -nle 'print map {sprintf "%02X",ord} split //'
For example, if I input "abcABC", the output will be "616263414243".
Please give a similar one-liner using binmode.
Thanks.
binmode
would be of no use at doing what you asked. There are currently no PerlIO layers that convert all output bytes but0A
to their ASCII hex representation.