I will need a bit more info on what you are trying to do in order to tell you what I think.
BTW, it is awkward to repeatedly test/trial-and-error a program which keeps asking user input from the command line. So, while testing your logic, perhaps you can hardcode some of those $input1, $input2. Or you can read them from a file (in this case you can test many different values), or if you are on a *nix command line printf "1\n5\n" | yourscript.pl or enter the values 1 and 5 in separate lines in myfile.txt and then cat myfile.txt | yourscript.pl