Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
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

Replies are listed 'Best First'.
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 taking refuge in the Monastery: (7)
As of 2016-06-29 22:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (388 votes). Check out past polls.