473,396 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Dates with Perl

Hey guys,
I am newbie to perl. I am trying to deal with dates ( such trying to find
what the date would be after month). Is therea function or date class( I am
a java programmer, I couldnt find the right word instead of class) to do the
job?
Thanks for any help.
Jul 19 '05 #1
4 9031
Firewalker wrote:
Hey guys,


Don't post separate messages to separate newsgroups.
You're supposed to post a single message to multiple groups
simultaneously. It's called cross-posting. Someone has
already answered in the alt.perl newsgroup.

Post to comp.lang.perl.misc instead of here (comp.lang.perl).
Jul 19 '05 #2
Firewalker wrote:
I am newbie to perl. I am trying to deal with dates ( such trying to
find what the date would be after month). Is therea function or date
class [...]


In spite your name you may want to put on your fireproof suit.

What happened when you asked Google (this question is asked often), asked
the FAQ (this question is asked often; although personally I find the FAQ
answer somewhat lacking), or asked CPAN (there are many modules to deal with
dates: http://search.cpan.org/search?query=date&mode=module)?

If your question would have been which module to use: typically people
recommend Date::Calc or Date::Manip the most.

jue
Jul 19 '05 #3
"Firewalker" <ha***@rogers.com> wrote in message
news:fv********************@rogers.com...
Hey guys,
I am newbie to perl. I am trying to deal with dates ( such trying to find
what the date would be after month). Is therea function or date class( I

am

that's easy:

use Date::Calc qw(Add_Delta_Days);

# get current date
@l_date = sub {($_[5]+1900, $_[4]+1, $_[3])}->(localtime);

# or set some other date
@l_date = (2004, 5, 8);

# add a week to @l_date
@l_date_week_after = Add_Delta_Days(@l_date, +7);

# subtract a week from @l_date
@l_date_week_before = Add_Delta_Days(@l_date, -7);

# print the stuff
printf ("l_date=%04d-%02d-%02d l_date_week_after=%04d-%02d-%02d
l_date_week_before=%04d-%02d-%02d\n", @l_date, @l_date_week_after,
@l_date_week_before);

but if you wannna know a date after a month you have to write a function
which handles year/month rollovers and uses Add_Delta_Days accordingly

--
dink.
Toyota MR2 Club Poland
www.mr2.pl

Jul 19 '05 #4
"Firewalker" <ha***@rogers.com> writes:
Hey guys,
I am newbie to perl. I am trying to deal with dates ( such trying to find
what the date would be after month). Is therea function or date class( I am
a java programmer, I couldnt find the right word instead of class) to do the
job?
Thanks for any help.


Welcome to comp.lang.perl

This newsgroup, despite it's level of activity, has been declared defunct in
Google
and in http://www.perldoc.com/perl5.8.4/pod...ost-questions-

You might want to familiarise yourself with the posting guidelines for
comp.lang.perl.misc at http://mail.augustmail.com/~tadmc/cl...uidelines.text
before posting there.

I note from your headers that you are a Windows user or at least you used MS
Outlook to post here. If you were using a Linux install of Perl then I would
say use:

man perl
man perlfaq
perldoc perldoc
perldoc perl

but I don't have a clue what documentation you'd get with Perl on Windows. (I
have heard that ActiveState Perl has a help button somewhere on the Start
button menu but can't verify this at all.)

You might want to browse http://www.perl.org, http://www.perldoc.com/, http://www.perl.com
and http://www.cpan.org for modules (the nearest Perl has to Java classes)

Also put Perl into a google search then trawl through the webpages you find
there and the group archives for answers to any questions you might have that
might have been answered already.

If you want to download modules from CPAN then check your perl documentation
to see if 'perl -MCPAN -e shell' will work or look for something similar. It
will do the installation work for you.

HTH

Lesley
Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

52
by: Olivier Scalbert | last post by:
Hello , What is the python way of doing this : perl -pi -e 's/string1/string2/' file ? Thanks Olivier
3
by: phal | last post by:
Hi all; I code Perl for CGI, I using regular expression to check the validation of user input, because the form is small and it run only from my own computer, anyways if many people using my...
2
by: cyber100 | last post by:
Is there an easy way to calculate how many days between two dates.. i have two dates and want to work out how many days between them, i have a static date and was getting todays date then working...
5
by: moddster | last post by:
Hi Guys. I am a newbie to perl and need some help with a problem. PROBLEM: I have to parse an HTML file and get rid of all the HTML tags and count the number of sumbissions a person has through...
5
by: pinpe | last post by:
Hi, I have problem of filtering a log file from my perl script. This is the file content of the file pinpe.csv: 2009-06-16 2009-01-29 2009-06-02 2008-03-05
12
by: aravicha | last post by:
Hi , i want a sample perl code to display all the dates between a date range. say, the start_date=18/03/2007 and end_date=18/04/2007. here i want to print all the dates beween 18/03/2007 &...
223
by: Pilcrow | last post by:
Given that UNIX, including networking, is almost entirely coded in C, how come so many things are almost impossible in ordinary C? Examples: Network and internet access, access to UNIX...
27
by: rhaazy | last post by:
I need to write some javascript that will return a date string in the form mm/dd/yyyy. The date needs to be today's date - 30 days. Is there a relatively straight forward way to do this? So...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.