Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Thanks Monks,

They all work well. However, except the perl one liners suggested no other scripts does what I wanted which in the end was to count the number ie 3 and print it on the screen!

Also, how do I adapt the scripts to do this for a list (a second file - random.txt) separated by space as shown in the example below:

2 3 2 3 2 1 2 1 3 2 1 3 3 3 1 3 1 2

Notice there is a space in the first line. The numbers are clustered in the manner in which the r's common to all columns should be counted. For example print only the r's in column 2, then print all the r's common in all rows of column 3 and 2, then print the r's common to all rows in column 3 , 2 and 1.

so the printed output for my file my_column_file.txt should below:

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 <p>should be:(the out put with explainations) </p> 4 3 3 (ie for 2 32 321) 4 5 3 (ie for 2 13 213) 5 5 3 (ie for 3 31 312) the out put desired 4 3 3 4 5 3 5 5 3

In reply to Re^2: Count similar characters in a row by $new_guy
in thread Count similar characters in a row by $new_guy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (9)
    As of 2014-10-01 11:47 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      What is your favourite meta-syntactic variable name?














      Results (9 votes), past polls