With my "just learning" PERL abilities, I have run into a quirk that I can't understand. It's in assigning a date value to a URL within my PL file.
I have success when I add a sub to the PL to establish the date. I want to assign tomorrow's date, which allows one to view records that have not yet expired, including those that will expire "tomorrow". I use the following:
#-------------------------------------
sub search_date {
# Returns tomorrow's date in the correct format
my ($time) = $_[0];
($time) or ($time = time());
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime(($time + 86400));
my (@months) = qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;
($day < 10) and ($day = "0$day");
$year = $year + 1900;
print qq|$day-$months[$mon]-$year|;
}
#--------------------------------------
I then call the date function within the "_home" sub inside of the PL file like this:
<area shape="rect" coords="303,89,391,111" href="$db_script_url?db=td&uid=default&view_records=1&expires-gt=|;
&search_date;
print qq|&sb=1&so=descend">
-----------------------------
This works great - initially. But, Once the program responds with "html_view_success," the value is a gonner! well, not quite - its new value is 1 Jan 1970 - big time warp[crazy]
What do I need to do to get the date back to its original value while inside of the html_view_success routine?
I tried to insert my date function inside of a separate routine that builds each page's top level lay out (the head, body tags, javascript/css source, etc - instead of repeating it in each sub routine). I did it this way:
sub html_pagebegin {
#This establishes the top format for each page
print qq|
<HTML>
<HEAD>
<TITLE>Training and Doctrine Directorate - </TITLE>
<LINK REL="stylesheet" TYPE="text/css"
HREF="$nimc/homepages.css">
<SCRIPT LANGUAGE="JavaScript1.2"
SRC="$nimc/nav.js">
<SCRIPT LANGUAGE="JavaScript1.2"
SRC="$nimc/nimc.js">
</SCRIPT>
</HEAD>
<BODY BGCOLOR="ffffff" ONLOAD="if (self != top) top.location = self.location">
(this goes on for a while until we get to the place where the value is needed, which begins now)
<area shape="rect" coords="303,89,391,111" href="$db_script_url?db=td&uid=default&view_records=1&expires-gt|;
# what is tomorrow's date?
my ($time) = $_[0];
($time) or ($time = time());
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime(($time + 86400));
my (@months) = qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;
($day < 10) and ($day = "0$day");
$year = $year + 1900;
print qq|$day-$months[$mon]-$year|;# OK - back to html
print qq|&sb=1&so=descend" alt="Items of Interest" title="Items of Interest">
(and then the sub goes on until its ending)...
This sub is called at the beginning of the _home sub like this:
sub html_home {
# --------------------------------------------------------
# The database manager home page.
&html_print_headers;
&html_pagebegin;
print qq|
And the HTML stuff begins here...
Again, everything works fine, tomorrow's date is firmly established until one goes somewhere within the database - like html_view_success - POW! the time warp happens again.
What am I missing??? Can someone get me pointed in the right direction?
Thank you (sorry for the long dialog)
[;)]
Mike Ferris
Tech Integration Staff
Training and Doctrine Directorate
National Geo/Intel College
Wash DC
I have success when I add a sub to the PL to establish the date. I want to assign tomorrow's date, which allows one to view records that have not yet expired, including those that will expire "tomorrow". I use the following:
#-------------------------------------
sub search_date {
# Returns tomorrow's date in the correct format
my ($time) = $_[0];
($time) or ($time = time());
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime(($time + 86400));
my (@months) = qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;
($day < 10) and ($day = "0$day");
$year = $year + 1900;
print qq|$day-$months[$mon]-$year|;
}
#--------------------------------------
I then call the date function within the "_home" sub inside of the PL file like this:
<area shape="rect" coords="303,89,391,111" href="$db_script_url?db=td&uid=default&view_records=1&expires-gt=|;
&search_date;
print qq|&sb=1&so=descend">
-----------------------------
This works great - initially. But, Once the program responds with "html_view_success," the value is a gonner! well, not quite - its new value is 1 Jan 1970 - big time warp[crazy]
What do I need to do to get the date back to its original value while inside of the html_view_success routine?
I tried to insert my date function inside of a separate routine that builds each page's top level lay out (the head, body tags, javascript/css source, etc - instead of repeating it in each sub routine). I did it this way:
sub html_pagebegin {
#This establishes the top format for each page
print qq|
<HTML>
<HEAD>
<TITLE>Training and Doctrine Directorate - </TITLE>
<LINK REL="stylesheet" TYPE="text/css"
HREF="$nimc/homepages.css">
<SCRIPT LANGUAGE="JavaScript1.2"
SRC="$nimc/nav.js">
<SCRIPT LANGUAGE="JavaScript1.2"
SRC="$nimc/nimc.js">
</SCRIPT>
</HEAD>
<BODY BGCOLOR="ffffff" ONLOAD="if (self != top) top.location = self.location">
(this goes on for a while until we get to the place where the value is needed, which begins now)
<area shape="rect" coords="303,89,391,111" href="$db_script_url?db=td&uid=default&view_records=1&expires-gt|;
# what is tomorrow's date?
my ($time) = $_[0];
($time) or ($time = time());
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime(($time + 86400));
my (@months) = qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;
($day < 10) and ($day = "0$day");
$year = $year + 1900;
print qq|$day-$months[$mon]-$year|;# OK - back to html
print qq|&sb=1&so=descend" alt="Items of Interest" title="Items of Interest">
(and then the sub goes on until its ending)...
This sub is called at the beginning of the _home sub like this:
sub html_home {
# --------------------------------------------------------
# The database manager home page.
&html_print_headers;
&html_pagebegin;
print qq|
And the HTML stuff begins here...
Again, everything works fine, tomorrow's date is firmly established until one goes somewhere within the database - like html_view_success - POW! the time warp happens again.
What am I missing??? Can someone get me pointed in the right direction?
Thank you (sorry for the long dialog)
[;)]
Mike Ferris
Tech Integration Staff
Training and Doctrine Directorate
National Geo/Intel College
Wash DC