GrepIt - Release Notes

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

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. <http://www.gnu.org/licenses/>
   GrepIt (gpit.pl): version 0.0.03
   Developed under : Perl v:5.42.3

Description

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.


If you have not yet developed a personal style for inserting temporary debugging code, perhaps today is a good day to begin; and although Software Sam would never push anyone toward his quirkey, OCD style of programming, it is hoped that the process of customizing  gpit.pl will suggest some possibilities.
At the very least you can experiment with the Perl syntax of this simple utility program while you are developing your coding style into an expression of pristine, artistic beauty.

So have fun – and as Software Sam always says:      OCD is not a disorder ‐ it's a skill set.  


Download and unpack the distribution archive.


Command-line Options for ‘gpit.pl’

Usage: gpit.pl SCAN_TOKEN [OPTIONS]

The SCAN_TOKEN character is required, and if not specified, then command-line help will be displayed.
All other options are optional.

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.



Tech Notes

The functionality available in any Perl script depends heavily upon the version of Perl installed and the modules loaded.
This script uses the standard modules available by default for the version currently installed, (experimental code is not used).
The version used for development of this project is: v5.42.3
The pragma used at the top of the file is: "use v5.40"

Multi-color Output In Perl

The command-line help text data of the GrepIt 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.
While an individual text string can be written using any available color attribute, a rainbow-colored paragraph can become a bit of a problem.
The Help() subroutine is based on two interlocking paragraphs, written in different colors.
Adjustments to the cursor position for each color segment are performed using standard ANSI escape sequences.
Please refer to the documentation for the author's AnsiCmd Library package for a full list of ANSI cursor positioning sequences, or refer to the ECMA-48 and ANSI X3.64 standards documents.
Two separate output routines are implemented. The first verifies that the terminal window height is sufficient to hold the entire text block. This allows us to output the interlocking blocks in only five lines of code. The second (more complex) implementation is executed if scrolling must occur during output.

Complicating this entire process is the fact that the Perl output routines do not output arrays of text as written, but instead a space is inserted into the output before each item of the array.
For this reason, the elements of our arrays are written individually within a loop.
Experimentation suggests that the automatic reformatting of an array written with a single output operation is some sort of brain-damaged design decision by the Perl maintainers, rather than an actual bug; so we had to implement the output loop as a work-around.