That's a little misleading, on second look (since you manufactured your
dates to work). You don't require content in all your captures, so you wind
up with the unintialized warnings. It's still bad practice not to check, and
feed data that doesn't match your pattern and you will get the messages for
the above reason.
Matt
Hey Matt,
I don't know what you mean by manufactured dates. Maybe this will
help:
elsif ($_ =~ /^([~\/-]+date$)/ || $_ =~
/^([~\/-]+date
/) {
if ($1 =~ /~/) {
$hCmdp{'Date'}->[0] = '~'; next;
}
$hCmdp{'Date'}->[0] = undef;
$hVars{'Date'} = '';
$hVars{'date_1'} = -1;
$hVars{'date_2'} = -1;
my $date_err = 0;
if ($_ =~ /^[\/-]+date
.+)$/) #($_
=~ /^[\/-]+date
[0-9\/,\*-]+)/)
{
my $date = $1;
#print "date = \"$date\"\n";
$hCmdp{'Date'}->[0] = $date;
$hVars{'Date'} = $date;
if ($date =~ /\*/) {
$hCmdp{'Date'}->[0] = '*';
$hVars{'Date'} = '*';
} else {
my @times = ();
# Date format:
# -##/##/## = all up to this
date
# ##/##/##- = all from this
date forward
# ##/##/##,##/##/## =
between these two dates
$date =~ /.*/;
$date =~
/^(?:\/*)([0-9]+)?(?:\/*)([0-9]+)?(?:\/*)([0-9]+)?(?:\/*)([,-]*)(?:\/*)([0-9]+)?(?:\/*)([0-9]+)?(?:\/*)([0-9]+)?(?:\/*)$/;
#print "date =
($1)($2)($3)($4)($5)($6)($7)\n";
if (length($1) == 0 &&
length($5) == 0) {
# error, invalid date
format ...
push (@ArgErrs, ['E',
$LOGINFO, $ERRLOG, '9016', (0,0,0,0), "$date", '', 1,0,1]);
$SHOWUSAGE = 1;
$date_err = 1;
} else {
my ($mo,$day,$yr,$cnt)
= (0,0,0,0);
if (length($1) > 0)
{
$cnt++ if
(length($3));
$cnt++ if
(length($2));
$cnt++ if
(length($1));
if ($cnt ==
3) { $mo=$1; $day=$2; $yr=$3; }
elsif ($cnt ==
2) { $mo=$1; $day=1; $yr=$2; }
elsif ($cnt ==
1) { $mo=1; $day=1; $yr=$1; }
if ($day < 1
|| $day > 31 || $mo < 1 || $mo > 12) {
#
error, date parameter out of range ... use default
push
(@ArgErrs, ['E', $LOGINFO, $ERRLOG, '9014', (0,0,0,0), "$mo/$day/$yr",
'', 1,0,1]);
$SHOWUSAGE = 1; $date_err = 1;
}
else {
# here
all is ok ...
#use
Time::Local 'timelocal';
#my
$time = timelocal($sec,$min,$hour,$mday,$mon-1,$year);
my
$time = 0;
eval
{$time = timelocal(0,0,0,$day,$mo-1,$yr);};
if
($@) {
#print "$@\n";
push (@ArgErrs, ['E', $LOGINFO, $ERRLOG, '9015', (0,0,0,0),
"\[$mo/$day/$yr\] $@", '', 1,0,1]);
$SHOWUSAGE = 1; $date_err = 1;
} else
{
push (@times, $time);
if (length ($5) == 0) {
push (@times, timelocal(0,0,0,1,0,2038)); # 2038, max int seconds
with 32-bit
#push (@times, 2**32 - 1);
}
}
}
}
($mo,$day,$yr,$cnt) =
(0,0,0,0);
if (length($5) > 0)
{
$cnt++ if
(length($7));
$cnt++ if
(length($6));
$cnt++ if
(length($5));
if ($cnt ==
3) { $mo=$5; $day=$6; $yr=$7; }
elsif ($cnt ==
2) { $mo=$5; $day=1; $yr=$6; }
elsif ($cnt ==
1) { $mo=1; $day=1; $yr=$5; }
if ($day < 1
|| $day > 31 || $mo < 1 || $mo > 12) {
#
error, date parameter out of range ... use default
push
(@ArgErrs, ['E', $LOGINFO, $ERRLOG, '9014', (0,0,0,0), "$mo/$day/$yr",
'', 1,0,1]);
$SHOWUSAGE = 1; $date_err = 1;
}
else {
# here
all is ok ...
#use
Time::Local 'timelocal';
#my
$time = timelocal($sec,$min,$hour,$mday,$mon-1,$year);
my
$time = 0;
eval
{$time = timelocal(0,0,0,$day,$mo-1,$yr);};
if
($@) {
#print "$@\n";
push (@ArgErrs, ['E', $LOGINFO, $ERRLOG, '9015', (0,0,0,0),
"\[$mo/$day/$yr\] $@", '', 1,0,1]);
$SHOWUSAGE = 1; $date_err = 1;
} else
{
push (@times, $time);
if (length ($1) == 0) {
push (@times, 86400); # 1,1,1970
}
}
}
}
}
$date =~ /.*/;
if ($date_err) {
$hCmdp{'Date'}->[0] =
undef;
$hVars{'Date'} = '';
$hVars{'date_1'} = -1;
$hVars{'date_2'} = -1;
next;
}
($hVars{'date_1'},
$hVars{'date_2'}) = sort { $a <=> $b } @times if (@times == 2);
}
}
else {
$hCmdp{'Date'}->[0] = '*';
$hVars{'Date'} = '*';
}
#print "date err = $date_err\ncmdp =
$hCmdp{'Date'}->[0]\ndate1 = $hVars{'date_1'}\ndate2 =
$hVars{'date_2'}\n";
#<STDIN>; exit (0);
}