[EMAIL PROTECTED] wrote: > Hi, Members > The script below produce an error at the printf function at line 342 which > says "Illegal division by zero at \perl\baccarat.pl line 342.". > Can someone tell me whats wrong. > Thanks > > ====partial script=================== > > my $total = $banker_counter + $player_counter; > open (BACCARAT_DATA,">>BACCARAT_DATA.txt") || die $!; > print BACCARAT_DATA "\n"; > > # the error starts here which is line 342 > printf BACCARAT_DATA "Total: Banker = $banker_counter (%2.0f%%), Player = > $player_counter (%2.0f%%),". > " Tie = $draw_counter (%2.0f%%).\n", > (($banker_counter / $total) * 100) , > (($player_counter / $total) * 100) , > (($draw_counter / ( $banker_counter + $player_counter + > $draw_counter )) * 100 ); >
Is it possible that $banker_counter and/or $player_counter are 0 at this point? That would appear to cause a divide by zero error...you might do some validation at that point and check the value of $total. - Josh -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/