Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: --- adding a column of integers

by ambrus (Abbot)
on Sep 03, 2004 at 20:35 UTC ( #388399=note: print w/replies, xml ) Need Help??


in reply to Re: --- adding a column of integers
in thread adding a column of integers

awk '{s += $0} END {print s}'

Also

(echo 0;sed s,$,+, inputfile;echo p)|dc
or even (with gnu sed)
sed ' G s/^ *\([0-9]*\) *\n\([0-9]*\)$/0\1pm0\2nb0/;td;d; :d;s/n\(\(b\).*0\|\)[^0]*$/nb98765432109876543210a0123456789\2/; s/\(.\)\(p.*\)\(.\)\(n.*\1\).*a.*\3/\2\4\3/; s/^0*\(.*\)p\(.*m\)0*\(.*\)\(.\).\{11\}$/0\1p\4\20\3/; /m0*n.*0/!bd; s/^\(.*\)p\(.*\)m.*/\1\2/;s/^0*//; h;$!d ' inputfile
but the point of the OP was to improve his Perl skills.

Update 2007 dec 6: see also Re: Golf: Adding up array elements

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://388399]
help
Chatterbox?
[Corion]: Weird - this "Install our backdoor SDK" spam is persistent. And I get the feeling it's not even automated, as it seems to be a re-forward of each mail, maybe even manually. Ah well, a quick rule in Thunderbird will move them to Spam automatically now :D
[Corion]: (the "backdoor SDK" is for distributing my software with an included backdoor, not for backdooring my own machine)
[marto]: ask for a trial
[marto]: then trick them into running your app
[marto]: once you have access, remove your email address from their system :P

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2018-05-25 14:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?