https://github.com/echo2echo/count-lines-of-code
Perl Script to Count Lines of Code of Perl, PHP and HTML Files. This script counts all supported files in a directory and each subdirectory.
https://github.com/echo2echo/count-lines-of-code
blank cloc code comments count count-lines html lines perl php
Last synced: 8 months ago
JSON representation
Perl Script to Count Lines of Code of Perl, PHP and HTML Files. This script counts all supported files in a directory and each subdirectory.
- Host: GitHub
- URL: https://github.com/echo2echo/count-lines-of-code
- Owner: echo2echo
- License: gpl-3.0
- Created: 2021-05-13T21:49:27.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-02-08T05:47:49.000Z (8 months ago)
- Last Synced: 2025-02-08T06:26:26.047Z (8 months ago)
- Topics: blank, cloc, code, comments, count, count-lines, html, lines, perl, php
- Language: Perl
- Homepage:
- Size: 74.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Count-Lines-of-Code
Perl Script to Count Lines of Code of Perl, PHP and HTML Files on Linux
Place script in directory with files and subdirectories to count
Grant permission to run script:
$ chmod 755 count_lines_of_code.pl
For script usage type the following without arguments.
$ ./count_lines_of_code.pl
or
$ perldoc count_lines_of_code.pl
For example, to count lines of all the Perl files in a directory and each subdirectory:$ ./count_lines_of_code.pl --type=Perl
For example, to count lines of all PHP files in a directory and each subdirectory:$ ./count_lines_of_code.pl --type=PHP
There is now support for counting .shtml and .htm files along with vanilla .html files. Use flag --type=HTML for each variation
For example, to count lines of all HTML files in a directory and each subdirectory:$ ./count_lines_of_code.pl --type=HTML
To count lines of code of a webpage, run something like the following in the same directory as the count_lines_of_code.pl script:
$ wget -cO - http://website.net > filename.htmlThen run the script...
$ ./count_lines_of_code.pl --type=HTML
To get a count for a single HTML file try a variation of the following...
$ ./count_lines_of_code.pl --type=HTML | grep -A 4 "filename.html"Or for a single Perl file...
$ ./count_lines_of_code.pl --type=Perl | grep -A 5 "filename.pl"
Files to be counted require read permission. If there is a permission error you could try running script with sudo, something like the following...
$ sudo ./count_lines_of_code.pl --type=Perl | grep -A 5 "filename.pl"To omit/skip counting the lines of code of the script itself in the summary of results when counting perl lines try something like below...
--omit usage
$ ./count_lines_of_code.pl --type=Perl --omit=count_lines_of_code.pl
*** --omit flag is still a work in progress. As a temporary work around, place the count_lines_of_code.pl script in a directory with a least one other perl file to be counted. ***
Until the --omit flag is fixed you will need at least 1 other perl file in the same directory as you are using the script in. Maybe create a small .pl file with the command below. Yes, the --omit flag has a bug.
$ echo "Fill text for script functionality" > omit.pl