?
Solved

perl script date/time help needed in a major way

Posted on 2003-02-24
3
Medium Priority
?
171 Views
Last Modified: 2006-11-17
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
Comment
Question by:jovato
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 320 total points
ID: 8013983
0
 
LVL 1

Expert Comment

by:tomclegg
ID: 8014448
@lt=localtime;
$currdate = sprintf("%04d%02d%02d%02d%02d%02d",
                    $lt[5]+1900,$lt[4]+1,@lt[3,2,1,0]);
0
 

Author Comment

by:jovato
ID: 8021234
thanks again
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question