How do I count the characters, words, and lines in a file, using Perl?

前端 未结 10 1410
醉酒成梦
醉酒成梦 2020-12-31 03:21

What is a good/best way to count the number of characters, words, and lines of a text file using Perl (without using wc)?

10条回答
  •  情书的邮戳
    2020-12-31 03:48

    This may be helpful to Perl beginners. I tried to simulate MS word counting functionalities and added one more feature which is not shown using wc in Linux.

    • number of lines
    • number of words
    • number of characters with space
    • number of characters without space (wc will not give this in its output but Microsoft words shows it.)

    Here is the url: Counting words,characters and lines in a file

提交回复
热议问题