Sidac has asked for the wisdom of the Perl Monks concerning the following question:
@list2 always ends up containing nothing ! Please give me some suggestions Thanks, Sidac42.034 41.630 40.158 26.823 26.366 25.289 23.949 34.712 35.133 35.185 35.577 28.463 28.412 30.831 33.490 33.839 32.059 32.072 33.425 33.349 34.709 <\code> the groups are always of equal length and can be arranged in more than + one line long, (if the group is large, say 500 numbers long); sepera +ted by blank lines ! My question is: how should I subtract the first element of array 2 fro +m array 1, array 3 from array 2, similarly for the second element and + so on till the end of the group? i.e.: 34.712-42.034,35.133-41.630,35.185-40.158 ...till the end of each grou +p 33.490-34.712,33.839-35.133 .................. I did use pairwise , use List::MoreUtils qw<pairwise>; But i am unable to assign them into array correctly <code> while (<IN>){ my @list1 = split ' ', <IN>; my @list2 = split ' ', <IN>; my @diff = pairwise { $b - $a } @list2, @list1; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: subtraction in array
by roboticus (Chancellor) on Mar 02, 2011 at 14:46 UTC | |
|
Re: subtraction in array
by toolic (Bishop) on Mar 02, 2011 at 14:29 UTC | |
|
Re: subtraction in array
by SuicideJunkie (Vicar) on Mar 02, 2011 at 14:24 UTC | |
|
Re: subtraction in array
by umasuresh (Hermit) on Mar 02, 2011 at 14:23 UTC | |
|
Re: subtraction in array
by Marshall (Canon) on Mar 02, 2011 at 21:04 UTC |