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

前端 未结 10 1377
醉酒成梦
醉酒成梦 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:28

    There is the Perl Power Tools project whose goal is to reconstruct all the Unix bin utilities, primarily for those on operating systems deprived of Unix. Yes, they did wc. The implementation is overkill, but it is POSIX compliant.

    It gets a little ridiculous when you look at the GNU compliant implementation of true.

提交回复
热议问题