Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi Folks,
Whats a nice one liner for adding a column of figures using perl ?
I'm not particularly happy with my solution
perl -ple '$sum=$_+$sum;$_=$sum;'|tail -1
but it works and reflects my baby-perl nicely.
I need some enlightenment to reach my next perl karma.
I'm not particularly happy with my solution
perl -ple '$sum=$_+$sum;$_=$sum;'|tail -1
but it works and reflects my baby-perl nicely.
I need some enlightenment to reach my next perl karma.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: adding a column of integers
by borisz (Canon) on Sep 02, 2004 at 13:23 UTC | |
Re: adding a column of integers
by ccn (Vicar) on Sep 02, 2004 at 13:28 UTC | |
by Eimi Metamorphoumai (Deacon) on Sep 02, 2004 at 14:19 UTC | |
by Smylers (Pilgrim) on Sep 02, 2004 at 16:10 UTC | |
by Anonymous Monk on Sep 02, 2004 at 21:19 UTC | |
by Smylers (Pilgrim) on Sep 03, 2004 at 08:31 UTC | |
by Random_Walk (Prior) on Sep 02, 2004 at 15:51 UTC | |
Re: adding a column of integers
by sleepingsquirrel (Chaplain) on Sep 02, 2004 at 14:52 UTC | |
Re: adding a column of integers
by kscaldef (Pilgrim) on Sep 02, 2004 at 16:14 UTC | |
Re: adding a column of integers
by sintadil (Pilgrim) on Sep 02, 2004 at 18:14 UTC | |
by sintadil (Pilgrim) on Sep 02, 2004 at 18:16 UTC | |
by Anonymous Monk on Sep 02, 2004 at 21:31 UTC | |
by cog (Parson) on Oct 04, 2004 at 13:35 UTC | |
Re: --- adding a column of integers
by Anonymous Monk on Sep 02, 2004 at 14:34 UTC | |
by ambrus (Abbot) on Sep 03, 2004 at 20:35 UTC | |
Re: adding a column of integers
by ambrus (Abbot) on Jun 26, 2006 at 18:25 UTC | |
by ikegami (Patriarch) on Jun 26, 2006 at 18:30 UTC |
Back to
Seekers of Perl Wisdom