in reply to foreach in array

You're making the assumption that your code skips the first element in the array. That assumption is wrong (very probably).

For example:

my @data = (0, 1, 2, 3, 4); # 5 elements foreach my $name (@data) { print "$name\n"; }
output:
0 1 2 3 4
I suggest you use warnings, strict and/or post more of your code because the problem isn't in this part of your program.