What is a good/best way to count the number of characters, words, and lines of a text file using Perl (without using wc)?
Perl – How to count the characters, words, and lines in a file, using Perl
countingfileperl
Related Topic
- Python – How to check whether a file exists without exceptions
- Python – How to get file creation & modification date/times in Python
- Java – How to create a Java string from the contents of a file
- C# – way to check if a file is in use
- Python – Writing a list to a file with Python
- Bash – How to split a large text file into smaller files with an equal number of lines
- Javascript – How to create a file in memory for user to download, but not through server
- Find duplicate lines in a file and count how many time each line was duplicated
Best Answer
Here's the perl code. Counting words can be somewhat subjective, but I just say it's any string of characters that isn't whitespace.