Copyright 2026-2027 by The Software Samurai.
On the web: http://www.SoftwareSam.us/
Software released under GNU GPL3, and documentation released under FDL1.3
GrepIt (gpit.pl): version 0.0.03 Developed under : Perl v:5.42.3
GrepIt (gpit.pl) is a Perl program which uses the “grep” system utility to scan source code for
specific constructs used during project development. The data are captured to a temporary file, then the 'less'
utility is used to display the results.
The author uses 'gpit.pl' when preparing distribution archives to ensure that all temporary
code has been removed, all debugging code is disabled, and that conditional-compilation directives are configured for
a production build.
For instance, this author writes temporary debugging messages and experimental code in this general style:
/* TEMP */ wcout << L"Call nckpConvert( " << conv_val << L" )" << endl ;
#if 1 // EXPERIMENTAL - Truncate to window width
gString gsRec ;
this->ReadRecord ( gsRec )
this->FormatRecord ( gsRec ) ;
if ( (gsRec.gscols()) > TermWidth )
{
gsRec.limitCols( TermWidth - 4 ) ;
gsRec.append( "..." ) ;
wcout << gsRec << endl ;
}
#endif // EXPERIMENTAL
Clearly, this kind of hack should not be included in a production build, so when preparing the distribution archive,
'gpit.pl' is used to identify these smelly constructs, so they can be removed:
┌──────────────────────────────────────────────────────────────────────────────────────────────────┐ │ [EarthPoints]$ gpit.pl a -src="EarthPoints.cpp EpParse.cpp" │ │ yields the report: │ │ EarthPoints.cpp:1262:/* TEMP */ wcout << L"Call nckpConvert( " << conv_val << L" )" << endl ; │ │ EpParse.cpp:598:#if 1 // EXPERIMENTAL - Truncate to window width │ │ EpParse.cpp:943:#endif // EXPERIMENTAL │ └──────────────────────────────────────────────────────────────────────────────────────────────────┘
Customizing the Scan
Every experienced software designer will have developed their own style for placing markers in their code to indicate
work-in-progress, so please modify gpit.pl to match your own, personal style.
gpit.pl will suggest some possibilities.gpit.pl - Perl script for scanning source code files Test1.cpp - Sample source code Test2.hpp README - Release notes (this file)
Usage: gpit.pl SCAN_TOKEN [OPTIONS]
TheSCAN_TOKEN character is required, and if not specified, then
command-line help will be displayed.ASCII character indicating the token for which to search.
| Scan Token | Token Text | Description |
|---|---|---|
| c | CZONE | Construction Zone – unfinished or untested code |
| e | EXPERIMENTAL | Experimental code – Sherlocking a problem |
| t | TEMP | Temporary code – report interim results |
| a | (all of the above) | Scan for and report all of the above tokens |
| d | #define DEBUG_ | Report all references to debugging code which is under conditional compile. |
| D | #define | Report all conditional compile directives. |
d – Report all instances of directives which include “DEBUG_” token. Examples: #if DEBUG_GCLA != 0 #endif // DEBUG_GCLA #define DEBUG_GCLA (1) d0 – Report only “DEBUG_” directives defined as zero (0). Example: #define DEBUG_ILOOP (0) // code block disabled d1 – Report only “DEBUG_” directives defined as non-zero. Example: #define DEBUG_ILOOP (1) // code block enabled D – Report all instances of all directives. Examples: #define PATH_MAX (1024) #define DLG_ROWS (16) #define HIDDEN_TREASURE "Dead Man's Cove" D0 – Report only instances of directives which are defined as zero (0). Examples: #define ENABLE_VERBOSE_OUTPUT (0) #define ENABLE_CURSES_BUG_FIX (0) D1 – Report only instances of directives which are defined as non-zero. Examples: #define ENABLE_VERBOSE_OUTPUT (1) #define FILEDLG_INCLUDED #define appVersion "1.2.14"Optional Parameters
Optional parameters are identified by one (or two) leading dash (hyphen) characters.
Parameters which require arguments are constructed using an ‘equals’ character: ‘=’
as shown in the examples below. Arguments which include whitespace must be enclosed within single or double quotes
so the shell program will interpret the argument as a single token.
*.[hc]pp” which indicates a
scan of all files in the CWD (current working directory) with a filename extension of either:
".cpp" or ".hpp".
'CZONE' tokens:
Test1.cpp:3
Test2.hpp:3
'EXPERIMENTAL' tokens:
Test1.cpp:3
Test2.hpp:3
'TEMP' tokens:
Test1.cpp:3
Test2.hpp:3
In each test source file, there are three instances of each token for which the data were scanned.
gpit.log”.
The temporary file to which the display data were captured is renamed and moved to the current working directory.
Tech Notes
The functionality available in any Perl script depends heavily upon the version of Perl installed and the modules loaded.Multi-color Output In Perl
The command-line help text data of theGrepIt application is written to 'stdout' in two colors:
green for options and blue for explanations and examples. This is done as a test of Perl output routines for multi-color text.Help() subroutine is based on two interlocking paragraphs, written in different colors.ANSI escape sequences.AnsiCmd Library package for a full list of ANSI
cursor positioning sequences, or refer to the ECMA-48 and ANSI X3.64 standards documents.