Perl server error when I try to divide two numbers?

WHAT?

New member
I haven't used Perl in a long time but I'm working on a CGI script. It works perfectly but will give me a server error if I try to divide!

ex.
$num = 50;
print "$num";

This works fine ... but if I do this:

$num = 10/50;
print "$num";

I get an error ... I have no clue how to solve this!
The program returns syntax errors from a subroutine using a switch statement which is called just before the division. The subroutine is fine though, it gives me correct data as long as I don't divide numbers it produces.
I finally got it to work by executing the code outside of the subroutine. This makes no sense to me at all, it shouldn't have given me syntax errors if it works outside of the subroutine.
 
>> The program returns syntax errors from a subroutine using a switch statement which is called just before the division

Are you trying to switch on $num? Because I'm pretty sure you can't use a fraction in a switch statement.
 
I am not so familiar with Perl, but I know that in some languages like Java there would be an issue with number types. For instance, your first example would be a whole number and in your second example your would have a decimal place. Maybe your types do not match?
 
Back
Top