paurus has asked for the wisdom of the Perl Monks concerning the following question:
What I am looking to do is get a final subtracted value. This is where I have stalled:$c = $a - $b;
So if the array was 4 3 1, the result would be (4 - 3 - 1) = 0... code ... sub subtraction{ chomp(@_ = split(" ", <STDIN>)); # user enters values on one line foreach(@_) { $result -= $_; # I guess I am using the WRONG operator } print "Result: $result\n\n"; ... rest of subroutine code ... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: simple math
by ysth (Canon) on Apr 22, 2004 at 04:16 UTC | |
|
Re: simple math
by Abigail-II (Bishop) on Apr 22, 2004 at 09:27 UTC |