Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- my $command = <STDIN>;
- my $counter = 1;
- #perform the add operation if the command is add
- if (($command eq 'add') || ($command eq 'a')){
- my $numIn = 0;
- my $currentNum = 0;
- #While NONE is not entered, input numbers.
- while ($numIn ne 'NONE'){
- if($counter == 1){
- print "nEnter the first number: ";
- }else{
- print "nEnter the next number or NONE to be finished.";
- }
- $numIn = <STDIN>;
- $currentNum = $currentNum + $numIn;
- $counter++;
- }
- print "nThe answer is: #currentNum n";
- #perform the subtract operation if the command is subtract
- }`
- $command =~ /^a/i
- chop($command)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement