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

Re^2: adding a column of integers

by Random_Walk (Prior)
on Sep 02, 2004 at 15:51 UTC ( [id://387948]=note: print w/replies, xml ) Need Help??


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

update - whoops

I just saw his tail -1 at the end, he is looking for a final total not a running one, DOH!. So option 2 below works just fine

Original dumb post

This does not work for me, is this my old perl (5.005_03) or am I doing something wrong ? If I add a continue it will work. Here is some output, I have added the > before the numbers I entered just for clarity.
:perl -lne "$sum+=$_}{print $sum" syntax error at -e line 1, near "+=" Execution of -e aborted due to compilation errors. :perl -lne '$sum+=$_}{print $sum' >1 >2 >3 :perl -lne '$sum+=$_}continue{print $sum' >1 1 >2 3 >3 6 >4 10
Cheers,
R.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://387948]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (2)
As of 2024-04-26 05:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found