I'm starting to learn perl using the Wrox Beginning Perl, available at perl.org , and you have a question regarding an example for the loop, they are given in chapter 3.
use warnings;
use strict;
my @count = (1..10);
for (reverse(@count)) {
print "$_...\n";
sleep 1;
}
print "Blast Off!\n"
This is the script that they provide, and works as expected. It displays a number followed by ... every second, waiting for a second between each number. When completed,Blast Off!
However, if I delete a new line from the print statement, the behavior will change. The script waits quietly for 10 seconds, and then displays all 10 numbers at Blash Off!once. Why change?
use warnings;
use strict;
my @count = (1..10);
for (reverse(@count)) {
print "$_...";
sleep 1;
}
print "Blast Off!\n"
source
share