<> wrote in comp.lang.perl.misc:
> I have a strange problem. I have a need to convert the value of a byte
> read from a file to its integer string counterpart. (e.g. the byte
> contains 0x1d and it prints out 29.)
> I use this to do it:
> $value = unpack ("c",substr($_, 259, 1));
>
> This seems to work just fine for all values except 0x0a which returns
> 32 instead of 10.
> Why does this happen?
> I wrote a similar script using awk which also returned 32 instead of
> 10.
> It seems so odd to me. 0x0b returns 11 which is correct as does all
> other values.
perl -le 'print unpack "c", chr 0x0a'
10
Have you checked the character you're accessing?
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
|