469,356 Members | 1,893 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,356 developers. It's quick & easy.

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 8730
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

52 posts views Thread by Olivier Scalbert | last post: by
3 posts views Thread by phal | last post: by
2 posts views Thread by cyber100 | last post: by
223 posts views Thread by Pilcrow | last post: by
27 posts views Thread by rhaazy | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.