in reply to Perl/TK hex2char - char2hex convertor
First, please pick an indentation style and stick with it. Check out perltidy.
Second, you are using foreach where you should be using map, and you are using map where you should be using foreach (or for). Try this instead:Use map when you want to transform one list (array) into another - don't use it in void context, use for (or foreach) instead. Other then that, looks good to me. :)sub convert_hex { my @charconv = map { pack "H*", $_ } split(/\s/, $hexval->get); $charval->delete(0, 'end'); $charval->insert(0, $_) for reverse @charconv; } sub convert_char { my @hexconv = map { unpack "H*", $_ } split(//, $charval->get); $hexval->delete(0, 'end'); $hexval->insert(0, $_) for reverse @hexconv; }
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)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Perl/TK hex2char - char2hex convertor
by Anonymous Monk on May 30, 2003 at 03:18 UTC | |
by jeffa (Bishop) on May 30, 2003 at 12:36 UTC |