in reply to Re: subroutines problem
in thread subroutines problem
i got this code but when i tested it i got no result: if ($ARGV[0] eq "add") { $rtn = add($ARGV[1]); print " The sum is $rtn"; } elsif ($ARGV[0] eq "multiply") { $rtn = multiply($ARGV[1]); print "ther prod is $rtn"; } sub add{ my ($sum); $sum=0; foreach $_(@_) { $sum +=$_; } return $sum; } sub multiply { my ($multiply); $product=0; foreach $_(@_) { $product+=$_; } return $multiply: } am i doing it right?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: subroutines problem
by NetWallah (Canon) on Jul 21, 2005 at 04:23 UTC |