Skip to content

Instantly share code, notes, and snippets.

@earnhardt3rd
Created June 19, 2023 13:56
Show Gist options
  • Select an option

  • Save earnhardt3rd/4b812ec0c79d1bf7dd5fadc2dba79c94 to your computer and use it in GitHub Desktop.

Select an option

Save earnhardt3rd/4b812ec0c79d1bf7dd5fadc2dba79c94 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 = &findMatch();}
1;
sub findMatch {
my $token = shift || "";
my $time = shift || "";
my $cron = shift || "";
print " findMatch($token,$time,$cron)\n" if $DEBUG > 99;
my %TOKENS = &splitter2HASH($cron,length($time));
my $matchCount=0;
if (scalar(keys %TOKENS) > 0) {
foreach my $tkey(sort keys %TOKENS) {
if ($tkey eq "*") {
printf " --time:%-10s %-2s:%-10s %-s\n",$time,$token,$tkey,"WILDCARD-MATCH" if $DEBUG > 99;
$matchCount++;
} else {
if ($tkey eq $time) {
printf " --time:%-10s %-2s:%-10s %-s\n",$time,$token,$tkey,"MATCH" if $DEBUG > 99;
$matchCount++;
} else {
printf " --time:%-10s %-2s:%-10s %-s\n",$time,$token,$tkey,"NO-MATCH" if $DEBUG > 99;
}
}
}
} else {
print " splitter2HASH($token,$cron) RETURNED NULL\n" if $DEBUG > 9;
}
return $matchCount;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment