If you comment the second line, $end will be undefined in the loop condition. Please, use strict and use warnings in your code if you want to learn Perl the easy way. This code works as expected:
use strict;
use warnings;
my @array=(1,2,3,4,5,6,7,8,9);
my $end=($#array+1);
my $index = 0;
while($index < $end){
my $last=pop(@array);
print "$last\n";
$index++;
}
BTW, here are another ways to address the same problem:
my @array = (1..9);
print +(pop @array),"\n" while (@array);
or even
my @array = (1..9);
print "array[$_]\n" for (reverse (0..$#array));