Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. my $command = <STDIN>;
  2. my $counter = 1;
  3. #perform the add operation if the command is add
  4. if (($command eq 'add') || ($command eq 'a')){
  5.  
  6. my $numIn = 0;
  7. my $currentNum = 0;
  8. #While NONE is not entered, input numbers.
  9. while ($numIn ne 'NONE'){
  10. if($counter == 1){
  11. print "nEnter the first number: ";
  12. }else{
  13. print "nEnter the next number or NONE to be finished.";
  14. }
  15. $numIn = <STDIN>;
  16. $currentNum = $currentNum + $numIn;
  17.  
  18. $counter++;
  19. }
  20.  
  21. print "nThe answer is: #currentNum n";
  22.  
  23. #perform the subtract operation if the command is subtract
  24. }`
  25.  
  26. $command =~ /^a/i
  27.  
  28. chop($command)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement