Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: perl onliner on multiple files

by igelkott (Priest)
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_*

Replies are listed 'Best First'.
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?
[erix]: o/
[erix]: I'm a bit stuck with regex capturing. Anyone wants to ahve a look at my [erix://pad | scratchpad ? (it's the little test program at the top there)]
[erix]: hm [erix://pad]
[erix]: pad::/erix
[erix]: erix's scratchpad
[erix]: ah! ;)
[erix]: I'm trying to capture some detail from user input I'm pretty sure I have done this before

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2018-01-19 08:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How did you see in the new year?










    Results (216 votes). Check out past polls.

    Notices?