in reply to Re^2: Floating point number counting script stuck in a loop
in thread Floating point number counting script stuck in a loop
When you use strict; (highly recommended btw.) you need to declare your variables so you need to stick my in front of the first assignment to $count. However, I'd be inclined to use a C type for loop in this case (note the declaration inside the loop header):
use strict; use warnings; for (my $count = 0.0; $count < 0.9; $count += 0.1) { print "$count\n"; } print "End!\n";
Note too that print doesn't need () and that variables can be interpolated directly into double quoted strings.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Floating point number counting script stuck in a loop
by Vonunov (Novice) on Oct 25, 2007 at 08:18 UTC | |
by dwu (Monk) on Oct 25, 2007 at 08:51 UTC | |
by GrandFather (Saint) on Nov 16, 2007 at 21:48 UTC | |
by dwu (Monk) on Nov 16, 2007 at 22:24 UTC | |
by Vonunov (Novice) on Oct 25, 2007 at 10:12 UTC | |
by GrandFather (Saint) on Oct 25, 2007 at 08:48 UTC |