# Program that will add or multiply as many numbers that are entered. # Use the program as such: program.pl add 3 2 1 use warnings; use strict; my $rtn; my $cmd = shift @ARGV; if ($cmd =~ /add/) { $rtn = add(@ARGV); print "The sum is: $rtn"; } elsif ($cmd =~ /multiply/) { $rtn = multiply(@ARGV); print "The product is: $rtn"; } sub add { my $sum = 0; my @data = @_; for (@data){ $sum += $_; } return $sum; } sub multiply { my $product = 1; my @data = @_; for (@data) { $product *= $_; } return $product; }