View Single Post
Old 05-25-2005, 04:17 PM   #4 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
Quote:
How I can put the current date in PERL
Read up on Date handling in perl
Code:
#!/usr/bin/perl
# Get the all the values for current time
($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime(time);
# In Perl, you'll need to increment the month by 1 
my $RealMonth = $Month + 1 ; # Months of the year are not zero-based
# Perl code will need to be adjusted for one-digit months
if($RealMonth < 10)
{
     $RealMonth = "0" . $RealMonth ; # add a leading zero to one-digit months
} 
# How to handle leading zero in day
if($Day < 10)
{
     $Day = "0" . $Day ; # add a leading zero to one-digit days
} 
# The year value will need some adjustment in Perl scripts
if($Year >= 100) {
    $Fixed_Year = $Year + 1900 ;
}
else
{
    $Fixed_Year = $Year + 2000;
}
print "$RealMonth/$Day/$Fixed_Year \n" ;
Please don't just edit your previus post, it won't keep the forum frontend updated, with showing the flashing button next to your thread, which is intended to catch the regular viewers attention.
And it will make the thread difficult to read, since theres no indication on what went on, in order to make sde or teknomage1 answer the way they do..

It was pure luck I noticed your real question, since I remembered something with this thread, and wanted to see if someone had followed up on your intentional question, about the error, when running a "used to work" script on another OS installation.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001

Last edited by redhead; 06-11-2005 at 02:16 PM.
redhead is offline   Reply With Quote