Skip to content

Instantly share code, notes, and snippets.

@earnhardt3rd
Created June 19, 2023 14:03
Show Gist options
  • Select an option

  • Save earnhardt3rd/1032ae9c00d4a01f72cdf0341239d0a3 to your computer and use it in GitHub Desktop.

Select an option

Save earnhardt3rd/1032ae9c00d4a01f72cdf0341239d0a3 to your computer and use it in GitHub Desktop.
require 'getopts.pl';
Getopts('m:d:t');
my $MODE = uc($opt_m) || "";
my $DEBUG = $opt_d || 0;
if (defined $opt_t) { my %TEST = &_SEARCH_HTMPL();}
1;
sub _SEARCH_HTMPL {
my $searchFor = shift || "";
if ($searchFor eq "") {return;}
my $htmplPath = $ROOTS{"NXROOT"} . $SLASH . "site" . $SLASH . "mods" . $SLASH . "www" . $SLASH . "htmpl";
if (! -d $htmplPath) {
print " ERROR! Could not locate path:$htmplPath!\n";
return;
}
chdir $htmplPath;
my $fCmd = "";
if (lc($^O) =~ /win/) {
$fCmd = "findstr /s /C:\"${searchFor}\" \*";
} else {
$fCmd = "grep -R $searchFor \*";
}
print " $fCmd\n";
my $fCmdX = `$fCmd 2>&1`;
my @R_LIST = split('\n',$fCmdX);
if (scalar(@R_LIST) <= 0) {
&displayMessageInBox(" There were no results found with:$fCmd \n");
}
for (my $ri=0;$ri<=scalar(@R_LIST)-1 ;$ri++) {
printf " %0.4d %-s\n",$ri,$R_LIST[$ri];
}
return @R_LIST;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment