Okay, so I want to create a loop that continuously asks for a set of three numbers, squares them, adds them together, then compares them. I'm not really done, so I apologize if you don't really get what I'm trying to do here.
Here's what I've got so far:
use warnings;
while(1==1){
print "Enter the first number: ";
$number1 = <STDIN>;
print "Enter the second number: ";
$number2 = <STDIN>;
print "Enter the third number: ";
$number3 = <STDIN>;
$total = $number3**2+$number2**2+$number1**2;
print "$total\n";
print "Are you done? Enter 1 for yes or 2 for no.\n";
$answer4 = <STDIN>;
if($answer4==1) {
last;
}
elsif ($answer4==2) {
redo;
}
}
## here I wanna compare the numbers
print "You have finished.";
I'm only a beginner at this, so I apologize if it's kinda simple.
But I want the scalar variable $total to be continuously re-evaluated for each time it loops, but add its original value to an array.
I don't really know if that's possible, but if it is, please help.