If I have an array like below, I can
index into it with a real number.
@bill = (2,4,6,8);
$bill[2.1515] returns the 6
Why is that? I'd expect to get some type
of addressing exception, but it appears
to truncate(or "integerize").
Just wondering if you know why that works?
I've searched around but couldn't locate
a reasonable answer.
Arrays in Perl are indexed with integer numbers, thus the index is
automatically converted just as you realized, it is truncated. That is the
way it goes. There is no more explanation. Perl will never give you error
in a situation when it can make a good guess what you may have wanted to
[ back to toc ]