in reply to Using Push and Pop.

foreach (@file) { my $test = pop (@file); print $test; }
That line modifies @file (with pop) while looping through it with foreach.

You should drop one of the statements for something better. I.e. change the foreach to while.

ps: print reverse <>; :-)