<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl
use strict;
use warnings;
use Regexp::Common qw /number/;

print "- Semplice Calcolatrice by Kiki -\n\n";
print "Inserisci primo numero:\n";
my $first = &lt;STDIN&gt;;
chomp($first);
while ($first !~ /^$RE{num}{real}$/ and $first !~ /^$RE{num}{int}$/)
{
	print "Non e` un numero\n";
	print "Inserisci un numero:\n";
	$first = &lt;STDIN&gt;;
	chomp($first);
}

print "E ora il secondo:\n";
my $second = &lt;STDIN&gt;;
chomp($second);
while ($second !~ /^$RE{num}{real}$/ and $second !~ /^$RE{num}{int}$/)
{
	print "Non e` un numero\n";
	print "Inserisci un numero:\n";
	$second = &lt;STDIN&gt;;
	chomp($second);
}


print "Ora scegli l'operatore:\n";
my $oper = &lt;STDIN&gt;;
chomp($oper);
  
while ($oper ne '+' and $oper ne '-' and $oper ne '*' and $oper ne '/')
{
	print "Ma che razza di operatore hai scelto\n";
	print "Inserisci un operatore corretto:\n";
	$oper = &lt;STDIN&gt;;
	chomp($oper);
}

if ($oper eq '+')
{
      my $somma = $first + $second;
      print $somma;

} elsif ($oper eq '-')

{
       my $sottrazione = $first - $second;
       print $sottrazione

} elsif ($oper eq '*')

{
      my $molti = $first * $second;
      print $molti;

} elsif ($oper eq '/')

{
      while ($second == 0)
      {
 		print "Scegli un denominatore diverso da 0, se no il prog non funzica\n";
	        $second = &lt;STDIN&gt;;
	        chomp($second);
      }
      my $divi = $first / $second;
      print $divi;
}

</pre></body></html>