$new_guy has asked for the wisdom of the Perl Monks concerning the following question:
How do I get the sum of integers in a column
for example:
The sum of the integers in the columns is: 14 182 3 3 4 4 5 5 6
My data is:
69 44 32 30 32 30 29 29 28 53 61 31 50 31 28 28 28 28 56 46 56 37 29 29 30 29 28 69 45 37 29 30 29 29 29 28 72 65 44 33 29 28 28 29 28 76 47 38 42 30 34 29 29 28 53 46 33 32 29 31 30 28 28 56 38 42 35 29 31 29 29 28 72 65 32 35 29 30 30 28 28 43 44 42 50 30 31 31 29 28 53 35 33 31 34 29 31 29 28 76 45 33 37 36 34 29 28 28 72 55 42 53 31 31 29 28 28 69 40 36 30 30 28 30 28 28
My script so far:
#!usr/bin/perl -w use integer; shift; while (<>) { $tot += $_ } print "$tot\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: sum of integers in a column
by muba (Priest) on Oct 12, 2010 at 12:25 UTC | |
by mjscott2702 (Pilgrim) on Oct 12, 2010 at 12:36 UTC | |
by muba (Priest) on Oct 12, 2010 at 12:41 UTC | |
by mjscott2702 (Pilgrim) on Oct 12, 2010 at 12:44 UTC | |
by ww (Archbishop) on Oct 12, 2010 at 22:00 UTC | |
|
Re: sum of integers in a column
by JavaFan (Canon) on Oct 12, 2010 at 13:49 UTC | |
|
Re: sum of integers in a column
by snape (Pilgrim) on Oct 12, 2010 at 16:41 UTC | |
|
Re: sum of integers in a column
by kcott (Archbishop) on Oct 12, 2010 at 21:40 UTC | |
by kcott (Archbishop) on Oct 12, 2010 at 23:53 UTC | |
|
Re: sum of integers in a column
by sbmp111 (Novice) on Oct 12, 2010 at 14:27 UTC | |
by sbmp111 (Novice) on Oct 12, 2010 at 14:52 UTC |