sub getdate{ my $ret = "$_[0]"; # Get the all the values for current time my ($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 add a leading zero in Perl if($Day < 10) { $Day = "0" . $Day; # add a leading zero to one-digit days } # How to use modulo arithmetic in Perl if($Year >= 100) { $Fixed_Year = ($Year % 100); } else { $Fixed_Year = $Year; } # 1900 is subtracted from the value returned from localtime # Add it back in to get a 4-digit year $Year += 1900; # Format the string the way we want if ($ret == "1"){ $today = "$RealMonth\/$Day\/$Year"; return $today; } else{ $today = "$Year$RealMonth${Day}_$Hour${Minute}"; return $today; } }