in reply to What way to weigh an AoA?

I think use warnings; and use strict; would go a long way toward solving this for you. You call your arrayref $user sometimes, and some of those may be in the code.

The last index of $users will be in $#$users, not $$#users. Observe,

$ perl -Mstrict -we'my $foo = ["a".."z"];print $#$foo,$/' 25 $ perl -Mstrict -we'my $foo = ["a".."z"];print $$#foo,$/' 14354 $
I'm not entirely sure what $$#users represents, but that explains your extra array elements.

I'm leery of your hash keyed to surname. When you insert Minnie, Mickey will get clobbered.

After Compline,
Zaxo