How to pause every iteration of the loop using sleep?

Viewed 64

Why does the whole process wait for 10 seconds before showing the results in the following code? I was expecting it to show each iteration every 1 second:

my @array = (1..10);
for (reverse(@array)){
    print $_, "\t";
    sleep 1;
}
print "\n";
1 Answers
Related