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.