Vonunov has asked for the wisdom of the Perl Monks concerning the following question:
Before I added -w and use strict;, the script would go into an infinite loop of this sort:#!/usr/bin/perl -w use strict; $count = .0; until ($count == .9) { $count = $count + .1; print ($count, "\n"); } print ("End!\n");
685.700000000087 685.800000000087 685.900000000087 686.000000000087 686.100000000087I'm sure it's something to do with the fact that I'm using floating point values. When I replace them with whole numbers, it counts one to ten then prints End! just wonderfully. I've tried zero-padding the values (as in 0.9 instead of .9) as well; this makes no difference. When I added -w and use strict;, I get this:
-bash-2.05b$ perl count
Global symbol "$count" requires explicit package name at count line 4.
{same for $count at lines 6, 8, 8, and 10}
Execution of count aborted due to compilation errors.
Am I supposed to be declaring $count as a floating point variable somehow?
|
|---|