Guest User

Untitled

a guest
Oct 18th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.31 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use warnings;
  4. use strict;
  5.  
  6. print "Please enter a list of numbers separated by space:\n";
  7.  
  8. sub equals {
  9.  
  10.  my $total = "0";
  11.  foreach (@_) {
  12.      $total += $_;
  13.  }
  14.  $total;
  15. }
  16.  
  17. my @nums;
  18. my $i = 0;
  19. while (<STDIN>) {
  20.     $nums[$i] = $_;
  21. }
  22. print 'Total is: ' . equals(@nums) . "\n";
Add Comment
Please, Sign In to add comment