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

Re: Count similar characters in a row

by suhailck (Friar)
on Oct 06, 2010 at 15:26 UTC ( #863816=note: print w/ replies, xml ) Need Help??


in reply to Count similar characters in a row

Try this,

perl -wle 'while(<>) { $count++ if "rrr" eq join "",(split)[1 .. 3] }; print $count' my_column_file.txt 3


Comment on Re: Count similar characters in a row
Download Code
Re^2: Count similar characters in a row
by jwkrahn (Monsignor) on Oct 06, 2010 at 16:00 UTC
    perl -lane '$count++ if "rrr" eq join "",@F[1 .. 3] }{ print $count' m +y_column_file.txt

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (10)
As of 2014-10-30 12:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (207 votes), past polls