On Fri, 2008-10-10 at 13:27 +0200, Dr.Ruud wrote:
> Deviloper schreef:
> 
> > while ($i < 0.8) {
> >     #do something which changes $i
> > }
> 
> Huh? That can easily still do one too much. 

Yes, that's the problem the OP was complaining about.

Try:
#!/usr/bin/perl

use strict;
use warnings;

my $lower_bound = 0.0;
my $upper_bound = 0.8;
my $iteration_step = 0.1;

my $half_step = $iteration_step / 2;
# for $i < $upper_bound, use $upper_bound - $half_step
# for $i <= $upper_bound, use $upper_bound + $half_step

my $i = $lower_bound;
while( $i < $upper_bound - $half_step ){
  print "$i\n";
}continue{
  $i += $iteration_step;
}

__END__

-- 
Just my 0.00000002 million dollars worth,
  Shawn

Linux is obsolete.
-- Andrew Tanenbaum


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to