Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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 contemplating the Monastery: (4)
As of 2015-07-06 04:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (70 votes), past polls