Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

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
Replies are listed 'Best First'.
Re^2: perl onliner on multiple files
by abhay180 (Acolyte) on Feb 09, 2013 at 10:12 UTC works.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2015-10-10 12:15 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (255 votes), past polls