$^W = 1; $index = 0..2; # this is your problem - it's initially undef @matching = qw(disk duck deck); $result = $matching[$index]; # and here's your problem, $matching[undef]!