Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: perl onliner on multiple files

by igelkott (Curate)
on Feb 08, 2013 at 21:30 UTC ( #1017891=note: print w/ replies, xml ) Need Help??


in reply to perl onliner on multiple files

Seems to work fine (on a reasonable number of files) if you want the total sum. If you want the sum per file, a minimal change would be to print and reset $c after each file ends.

For example:
perl -e ' while (<>) { if (/: /) { $c += (split /: /)[0]; } if(eof) { print "SUM.$ARGV =$c\n"; $c=0; } }' tmp_*


Comment on Re: perl onliner on multiple files
Download Code
Re^2: perl onliner on multiple files
by abhay180 (Acolyte) on Feb 09, 2013 at 10:12 UTC
    Great...it works.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2015-07-04 03:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls