On 4/17/09 Fri Apr 17, 2009 10:02 AM, "Brian" <brian5432...@yahoo.co.uk> scribbled:
> Hi > I had this semi-working, changed something and can't remember where I > went right, so would appreciate some help getting back on top. > > I know 1..10 and 2..10 probably won't work in the following example, I > have just changed lines to show what I am trying to get. > > $mystart = -2; > $i = 1; > > for ($i = 1..10 ) { for my $I ( 1..10 ) { > > while ($i = 1 ) { '=' is assignment, '==' is test for numerical equality. This loop will never end, as $I gets assigned to the value 1 each time through the loop. while( $i == 1 ) { > if ($mystart < 1 ) {print "line 1 no data"} > if ($mystart > 0 ) {print "line 1 data"} > $mystart++ ; $i++; You probably don't want to change $i inside a 'for my $I ( 1 .. 10 )' loop, as the change will be overwritten at the next loop iteration. If you really need to modify the loop iterator, then you should use a C-style for loop: for( my $i = 0; $i <=10; $i++ ) { ... } -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/