in reply to (jeffa) Re: Perl/TK hex2char - char2hex convertor
in thread Perl/TK hex2char - char2hex convertor

I guess I am the only one, but I was not able to successfully run the script. I get a error "Unrecognized character \xAD at test.pl line 4." when I execute it. I am not a Perl programmer but I need to convert a file from hex to chars. Any idea why? Thanks Dan

Replies are listed 'Best First'.
(jeffa) 3Re: Perl/TK hex2char - char2hex convertor
by jeffa (Bishop) on May 30, 2003 at 12:36 UTC
    This is probably the wrong thread ... check out converting hex to char instead. Also, the following might be more helpful for what you need:
    use strict; use warnings; print char2hex('a'),$/; print hex2char(62),$/; sub char2hex { return sprintf('%x',ord($_[0])); } sub hex2char { return chr(hex($_[0])); }
    Goo luck :)

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)