Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^3: problem count the number of words -- oneliner

by pme (Prior)
on Dec 26, 2018 at 17:16 UTC ( #1227718=note: print w/replies, xml ) Need Help??


in reply to Re^2: problem count the number of words -- oneliner
in thread problem count the number of words

Hi kschwab,

Are you sure? This one gives the same result like wc.

perl -ne 's/\S+/$i++/egi;END{print "$i\n"}' f1 f2

Replies are listed 'Best First'.
Re^4: problem count the number of words -- oneliner
by kschwab (Vicar) on Dec 26, 2018 at 17:38 UTC
    Guess it depends on what OP means by "all words", but sure.
    # works like wc perl -ne 's/\s+/$i++/eg;END{print "$i\n"}' f1 f2
    Not sure why you have the "i" modifier.
      You are right, we do not need "i".

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2020-10-19 16:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (205 votes). Check out past polls.

    Notices?