Wte a program in perl that have two subroutines add and


Write 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 {
...
}

(Hint: $#ARGV can be used to determine how many values were specified on the command line. The length of an array is also retrieved by writing something like $len = @ARGV.)

 

Solution Preview :

Prepared by a verified Expert
Programming Languages: Wte a program in perl that have two subroutines add and
Reference No:- TGS01244730

Now Priced at $20 (50% Discount)

Recommended (98%)

Rated (4.3/5)