in reply to Illegal hexadecimal digit error

That's a warning, not an error ... it results from trying to convert a hex 'number' which has a newline in it. Remove the newline:
my $hex_num = '0x' . sprintf('%x', $dec_num);
Also, don't use quotes when you copy $hex_num to $num at the end of the loop (it doesn't make a difference here, but it is a bad habit to get into).

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'.
Re: Illegal hexadecimal digit error
by tadman (Prior) on Jul 07, 2003 at 17:43 UTC
    Or even better, put it all in sprintf:
    my $hex_num = sprintf("0x%x", $dec_num);