in reply to Using Push and Pop.

Why are you popping entries off the end of the @file list inside a loop where you are iterating over the entries in @file?

for my $f (reverse @file) { print $f; }
Or
while (@file) { print pop @file; }