Create a program in perl-subroutines


Discussion:

Q: Create a program in PERL that have two subroutines add() and multiply() that will add or multiply its arguments and print the result to screen.

The values must returned from the add and multiply functions, back to the main program before the value is printed. The body of the code might look something like the following:

if ($ARGV[0] =~ /add/) {
$rtn = add($ARGV[1], ...]);
print "The sum is: $rtn";
}
elsif ($ARGV[0] =~ /multiply/) {
$rtn = multiply($ARGV[1], ...]);
print "The product is: $rtn";
}

sub add {
...
}

sub multiply {
...
}

Solution Preview :

Prepared by a verified Expert
Programming Languages: Create a program in perl-subroutines
Reference No:- TGS01938440

Now Priced at $20 (50% Discount)

Recommended (98%)

Rated (4.3/5)