Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 05-20-2005, 05:18 AM   #1 (permalink)
fabbasey
Recruit
 
Join Date: Mar 2005
Posts: 10
fabbasey is on a distinguished road
Unhappy Problem with Perl Code

Hi Everyone,
How I can put the current date in PERL

Thanks

Last edited by fabbasey; 05-23-2005 at 08:01 AM.
fabbasey is offline   Reply With Quote
Old 05-20-2005, 07:04 AM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
i'm no perl expert here, but might it have to do with the version of perl? or perhaps the perl modules that were installed?
__________________
Mike
sde is offline   Reply With Quote
Old 05-20-2005, 12:05 PM   #3 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 596
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
Right, you're going to have to put up some error messages to give us some clues. Maybe try running the code with '-w' to get some more verbose errors?
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Old 05-25-2005, 03:17 PM   #4 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,694
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 01:16 PM.
redhead is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
JSP code problem j.gohel Java 7 04-15-2005 02:07 PM
{perl} HTTP Error Code Response gty All Other Coding Languages 2 09-08-2004 11:09 AM
paramerters in perl & an input problem Apodysophilia All Other Coding Languages 4 12-24-2003 11:30 AM


All times are GMT -8. The time now is 08:58 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting