P
Paul D
Hi all
Please forgive me for the simplistic and inefficient nature of the following
program - I am working through the early chapters of a "Teach yourself Perl"
book.
Could someone tell me why Program 1 leaves a gap between the first and
second lines of the descending list of numbers that it outputs, which is in
contrast to Program 2 which prints a continuous list?
I'd be very greatful for your explanation
Many thanks
Paul
= = = = = = = Program 1 = = = = = = =
#!/bin/perl
print ("Enter a number\n");
$number = <STDIN>;
print ("\n\n\n");
$count = $number;
$done = 0;
until ($done == 1) {
print ($count,"\n");
if ($count == 1) {
$done = 1;
}
$count = $count - 1;
}
= = = = = = = Program 2 = = = = = = =
#!/bin/perl
$number = 10;
print ("\n\n\n");
$count = $number;
$done = 0;
until ($done == 1) {
print ($count,"\n");
if ($count == 1) {
$done = 1;
}
$count = $count - 1;
}
Please forgive me for the simplistic and inefficient nature of the following
program - I am working through the early chapters of a "Teach yourself Perl"
book.
Could someone tell me why Program 1 leaves a gap between the first and
second lines of the descending list of numbers that it outputs, which is in
contrast to Program 2 which prints a continuous list?
I'd be very greatful for your explanation
Many thanks
Paul
= = = = = = = Program 1 = = = = = = =
#!/bin/perl
print ("Enter a number\n");
$number = <STDIN>;
print ("\n\n\n");
$count = $number;
$done = 0;
until ($done == 1) {
print ($count,"\n");
if ($count == 1) {
$done = 1;
}
$count = $count - 1;
}
= = = = = = = Program 2 = = = = = = =
#!/bin/perl
$number = 10;
print ("\n\n\n");
$count = $number;
$done = 0;
until ($done == 1) {
print ($count,"\n");
if ($count == 1) {
$done = 1;
}
$count = $count - 1;
}