http://www.perlmonks.org?node_id=1044151


in reply to what does "use of uninitialized value" really mean?

"Use of uninitialized value in array element" occurs when you use undef as an array index:

use strict; use warnings; my @array = (5, 10); my $index = undef; print $array[$index];

It would still output "5" (in addition to the warning), by interpreting undef as 0 - which may or may not be what you intended (hence the warning).

To get rid of the warning, make sure that any variable or expression that is used as an array index will never be undef. If the undef values occured by accident, fix the bug. If you're sure that undef values are no accident and that they should indeed be interpreted as 0, you can make that explicit for example using the // operator:

print $array[$index//0]