Does having an if statement inside a for loop cause problems? My problem is that I have an if statment inside a for loop and for some reason causes my for loop not to increment the value of i.
ie.
for($i=1; $i <= $num_checks; $i++)
Below is the sub- routine thats causing me problems. I know there are a lot of things I can to to make this shorter, but I'm fairly new to perl and need to get this done quick.
sub error_checking {
for($i=1; $i <= $num_checks; $i++)
{
print "************************************************* **************\n";
print "* Worcester Youth Center Check # $i\n";
print "* 27 Chandler St.\n";
print "* Worcester, Ma 01609\n";
print "* Date $date[]\n";
print "*\n";
print "* Pay to: $pay_to[i] \$$amount_num[i]\n";
print "*\n";
print "* Note: $note[i]\n";
print "************************************************* **************\n";
if ($i%2 == 0)
{
print "Are these checks correct? (y/n) ";
chomp ($yesno = <STDIN>);
if ($yesno eq "n") {
&edit;}
}
}
if ($i%2){
print "Are these checks correct? (y/n) ";
chomp ($yesno = <STDIN>);
if ($yesno eq "n") {
&edit;}}
}


Reply With Quote
Bookmarks