On Sun, Mar 16, 2008 at 12:20 AM,  <[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 );
>

Either $total or ( $banker_counter + $player_counter + $draw_counter )
is zero, and you can't divide by zero.

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


Reply via email to