Loading ...
Sorry, an error occurred while loading the content.

26967Counting the number of occurances of all paragraphs in a file

Expand Messages
  • Prateek Mathur
    Jul 20, 2010
    • 0 Attachment
      Hi,

            I want to count the number of times every paragraph appears in a text file.
      I want to print those paragraphs and the count of how many times they appeared if the count is more than 1.

      e.g:
      file:

      p1

      p2

      p3

      p1

      p3

      p3

      It should print:
      p1
      Appeared 2 times

      p3
      Appeared 3 times.
       
      and so on for all the paragraphs that appear more than once.

      Let me know how can I do this Perl. I came across the split function but then that has to be used for every paragraphs and the text file can be very big as well to store in a single array.
      Also many paragraphs will appear only once which are not to be considered.

      Thanks in advance

      Prateek Mathur







      [Non-text portions of this message have been removed]
    • Show all 3 messages in this topic