[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 311
  • Last Modified:

Including "date" in cgi file(perl)

Hi,
In my test.pl file I have included "date" variable:

$mydate=`date`
print "$mydate\n";

But while I run test.pl from MS/DOS, the perl program outputs today's date after i "enter twice" after typing test.pl !!
Also when I include the above two lines in my .cgi script(perl), today's date does not show up!

saurav
0
saurav
Asked:
saurav
1 Solution
 
ozoCommented:
$mydate=localtime;
0
 
wilfriedsCommented:
This seems definitely not the way to get the date in Perl.  It looks to me as if you're trying to get the result of the MSDOS command date into a variable.
You have to use Perl's time function instead.
localtime(time) will give you a 9-element array which a.o. includes today's day.

Cfr. Camel book p. 159
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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