Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
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 wandering the Monastery: (5)
As of 2014-08-23 00:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (168 votes), past polls