- or download this
my $op = shift @ARGV;
if ( $op eq 'add' ) {
...
my $rtn = multiply( @ARGV );
print "The product is: $rtn\n";
}
- or download this
sub add {
my $sum = 0;
...
}
return $sum;
}
- or download this
sub add {
my $sum = 0;
$sum += $_ for @_;
return $sum;
}
- or download this
#!/usr/bin/perl --
use strict;
...
);
$ops{$op}(@ARGV) if exists $ops{$op};
- or download this
#!/usr/bin/perl --
use strict;
...
( $result = 1, map { $result *= $_ } @ARGV );
print ( $op eq 'add' ? 'The sum is:' : 'The product is:' );
print " $result\n";