in reply to What does $#variable mean?

it's the last index of the array @SORTEDLENDERS. so if it has 5 elements, the last index would be 4, as indizes are from 0..4.
in case the array is empty the last index is -1.
for details (and exceptions) please refer to perldata