• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 172
  • Last Modified:

perl script date/time help needed in a major way

I have a script called tester.pl. I need a parameter created that is yearmonthdayhourminutesecond. I then need to use that parameter in the script to name a field and also to name the file as it is saved. I have asked this question in another EE section, but I am not getting very far. Any and all help is truely welcome as time is running out. Here is the tester.pl:

NOTE: The $currdate parameter at the end of the script is what I need to list out as yearmonthdayhourminutesecond.

#!/usr/bin/perl

use CGI;
use CGI::Carp qw(fatalsToBrowser);


my $q = new CGI;
print $q->header;
my %param = $q->Vars;




my $template = <<"EOF";
<html>
<head>
<title>cpconfig.com KB: $param{issue}</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000" link="#FF0000" vlink="#FF0000" alink="#FF
0000">
<center>
<table width="600" border="1" cellpadding="0" cellspacing="0">
  <tr>
    <td width="600" height="550" valign="top">
      <div align="center">
        <p><b><font face="Verdana, Arial, Helvetica, sans-serif" size="4" color=
"#999999"><br>
        </font><font face="Fixedsys" size="6" color="#000000">cpconfig</font></b
></p>
      </div>
      <div align="center">
        <b><font face="Fixedsys" size="2">KnowledgeBase</font></b></div>
      <blockquote>
        <div align="center">
          <hr>
          <font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#99
9999">&nbsp;|
          <a href="#">cpconfig forum</a> | <a href="#">Home</a>
          | <a href="#">Documentation</a> |
          <a href="#">FAQ</a> | <a href="#">Links</a> | <a href="#">KB Help</a>
|</font><div align="left">
            <hr>
            &nbsp;
            <p>
<b><font face="Verdana" size="2">KBID</font></b>: </P>$currdate</font></P>

            <font face="Verdana" size="2"><b>Issue:</b></font>
<p><font face="Verdana" size="2">$param{issue}</font></P>
            <p><font face="Verdana" size="2"><b>Version:</b></font></P>
<p><font face="Verdana" size="2">$param{version}</font></P>
            <font face="Verdana" size="2"><b>Platform:</b></font>
<p><font face="Verdana" size="2">$param{platform}</font></P>
            <p><font face="Verdana" size="2"><b>Abstract:</b></font></P>
<p><font face="Verdana" size="2">$param{abstract}</font></P>
            <font face="Verdana" size="2"><b>Solution:</b></font>
<p><font face="Verdana" size="2">$param{solution}</font></P>
            <p><font face="Verdana" size="2"><b>Links/Sources:</b></font></P>
<p><font face="Verdana" size="2">$param{links}</font></P>
            <font face="Verdana" size="2"><b>Submitted By:</b></font>
<p><font face="Verdana" size="2">$param{submitted}</font></P>
            <p>&nbsp;</p>
            <p><font face="Verdana, Arial, Helvetica, sans-serif" color="#999999
" size="1"><i>
            DISCLAIMER: The
            following information is believed to be accurate. If you find
            anything wrong with any of the documentation, please e-mail us at
            <a href="mailto:docs\@cpconfig.com?subject=KnowledgeBase problems">k
b\@cpconfig.com</a> and let us know. We take no responsibility for
            the accuracy or completeness of the documentation here. As always,
            please test everything in a lab environment and not in production.</
i></font></p>
            <p>&nbsp;</p>
          </div>
        </div>
      </blockquote>
    </td>
  </tr>
</table></center>
</body>
</html>
EOF


open (FILE, ">/usr/local/apache/htdocs/knowledgebase/$currdate.html")  or die "C
an not open $currdate.html $!\n";
print FILE $template;
close (FILE);

print "<h1>Created File</h1>";
exit;
0
jovato
Asked:
jovato
1 Solution
 
tomcleggCommented:
@lt=localtime;
$currdate = sprintf("%04d%02d%02d%02d%02d%02d",
                    $lt[5]+1900,$lt[4]+1,@lt[3,2,1,0]);
0
 
jovatoAuthor Commented:
thanks again
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now