in reply to Using Push and Pop.

foreach (@file) { my $test = pop (@file); print $test; }

should be

while (@file) { my $test = pop (@file); print $test; }

In reply to your updated question,

while (@file) works because it evaluates the size of @file before each iteration.

foreach (@file) processes element 0 on the first pass, element 1 on the second pass, etc. On the 14th pass, it should process element 13. However, the loop ends because @file only has elements 0 through 12 left.