I have been doing a simple example of a calculator using html and perl with the CGI module but I do not understand the error here is the HTML form
<form id="formu" action="multiplicar.cgi" method="POST" class="form register">
<h2 class="form_titulo"> Calculadora </h2>
<div class="contenedor-inputs">
<br>
<input type="text" name="numero" id="nombre" placeholder="Ingresa el número " maxlength="2" class="input-100" required />
<input type="text" name="numero2" id="nombre" placeholder="Ingresa el número " maxlength="2" class="input-100" required />
<input type="radio" name="opcion" value="sumar" /> Suma <br />
<input type="radio" name="opcion" value="restar" />Resta<br />
<input type="radio" name="opcion" value="multiplicar" />Multiplicación<br />
<input type="radio" name="opcion" value="dividir" />Division<br /> '
</td>
<input class="form-btn" type="submit" id="btnenviar" value="Ingresar"/>
</div>
</form>
And the perl code with the CGI module is as follows:
#!"C:\xampp\perl\bin\perl.exe"
use strict;
use CGI;
my $cgi = new CGI;
my $num = $cgi->param('numero');
my $num2 = $cgi->param('numero2');
my $op = $cgi->param('opcion');
if ($op eq "sumar") {
$total = $num+$num2;
}
elsif ($op eq "restar") {
$total = $num-$num2;
}
elsif ($op eq "multiplicar") {
$total = $num*$num2;
}
elsif ($op eq "dividir") {
if ($num2 <= 0) {
$total = "No se puede dividir entre 0";
}
else {
$total = $num/$num2;
}
}
else {
$total = "opción inválida";
}
print $cgi->header("text/html");
print $total;