Rob Dixon wrote: > > 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 will > do > 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/