in reply to Count similar characters in a row
An alternative using tr (see Transliteration in Quote and Quote like Operators) to count the number of 'r's.
knoppix@Microknoppix:~$ perl -E ' > open my $fh, q{<}, \ <<EOD or die $!; > 0 a b h > 1 - r z > 3 u - u > 4 r x r > 5 r t r > 6 r r r > 7 r r r > 8 r r r > EOD > > while ( <$fh> ) > { > my( $seq, @cols ) = split; > print if tr{r}{} == scalar @cols; > }' 6 r r r 7 r r r 8 r r r knoppix@Microknoppix:~$
Cheers,
JohnGG
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Count similar characters in a row
by $new_guy (Acolyte) on Oct 07, 2010 at 11:33 UTC | |
by johngg (Canon) on Oct 07, 2010 at 13:50 UTC | |
by $new_guy (Acolyte) on Oct 08, 2010 at 08:19 UTC | |
by johngg (Canon) on Oct 08, 2010 at 09:15 UTC | |
by $new_guy (Acolyte) on Oct 08, 2010 at 10:56 UTC |
In Section
Seekers of Perl Wisdom