473,750 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 9049
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.c om> wrote in message
news:fv******** ************@ro gers.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_Da ys);

# 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_af ter = Add_Delta_Days( @l_date, +7);

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

# print the stuff
printf ("l_date=%04 d-%02d-%02d l_date_week_aft er=%04d-%02d-%02d
l_date_week_bef ore=%04d-%02d-%02d\n", @l_date, @l_date_week_af ter,
@l_date_week_be fore);

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.c om> 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
3764
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
2466
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 form, do you think it will be slow due to Perl is run under server. How about using JavaSCript to check validation for user input? Do you think it a bit faster?
2
4146
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 out for each what the day of the year was and subtracting the two, this worked fine until the new year.. now i have dates from 2006 and todays date of 2007 and obviously cant use the day of the year function as the 2007 date is less than the 2006...
5
2333
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 out the dates found. The condition is that multiple submissions by the same person on the same date is counted as 1. I have already gotten rid of the HTML tags using: #!/usr/bin/perl -w use strict;
5
2413
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
8404
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 & 18/04/2007 in perl. Plesae help at the earliest.
223
7290
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 interprocess controls and communication, locale determination, EBCDIC/ASCII discrimination, etc. Almost all of these are easy in Perl. Why isn't there a mechanism like perl modules to allow easy extentions for facilities like these? Isn't anyone working...
27
1767
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 far all I can find is a mess of variables for month, day, and year, and combining some date functions together, etc etc. Seems like a lot of work for what should be very simple.
0
9000
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8838
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9577
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9396
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9339
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8260
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4713
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4887
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2804
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.