Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^3: How can you make this script general?

by soonix (Deacon)
on Mar 08, 2014 at 21:05 UTC ( #1077560=note: print w/ replies, xml ) Need Help??


in reply to Re^2: How can you make this script general?
in thread How can you make this script general?

perhaps tangent wants to be prepared for the general case, where the columns have names...


Comment on Re^3: How can you make this script general?
Re^4: How can you make this script general?
by BrowserUk (Pope) on Mar 08, 2014 at 22:01 UTC
    to be prepared for the general case, where the columns have names...

    Still makes no sense to waste cycles sorting hash keys:

    #! perl -slw use strict; my @colnames = split ' ', <DATA>; my @totals; while( <DATA> ) { my @cols = split; $totals[ $_ ] += $cols[ $_ ] for 0 .. $#cols; } printf "%10s:%u\n", $colnames[$_], $totals[$_] for 0 .. $#totals; __DATA__ alpha beta gamma delta 1 2 3 4 5 6 7 8 9 10 11 12

    Produces:

    C:\test>junk alpha:15 beta:18 gamma:21 delta:24

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
    i

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2014-08-30 14:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (293 votes), past polls