Re: perl cumulative module question
- From: ben.perl3@xxxxxxxxx (Ben Perl)
- Date: Thu, 27 Nov 2008 06:35:23 -0800
Thanks Everyone!! This should help.
On Sat, Nov 22, 2008 at 9:17 AM, Rob Dixon <rob.dixon@xxxxxxx> wrote:
Rob Dixon wrote:
will do
Your arithmetic is odd. You say
9-4 = 2
and so your resulting list should be (2,4,2). If you want to subtract the
previous result from the next item in your data list each time then this
the job.
HTH,
Rob
use strict;
use warnings;
my @data = (2, 6, 9);
my @delta = @data;
my $prev = 0;
$prev = $_ = $_-$prev for @delta;
print "@delta\n";
**OUTPUT**
2 4 5
Jay's solution is very similar but preferable to mine.
Rob
--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
http://learn.perl.org/
- References:
- perl cumulative module question
- From: "ben perl"
- Re: perl cumulative module question
- From: Rob Dixon
- Re: perl cumulative module question
- From: Rob Dixon
- perl cumulative module question
- Prev by Date: Re: Module location - auto vs elsewhere
- Next by Date: Re: Module location - auto vs elsewhere
- Previous by thread: Re: perl cumulative module question
- Next by thread: How Do I Auto-Run Perl in a Browser
- Index(es):
Relevant Pages
|
Loading