473,508 Members | 2,333 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Modifying Date value in this short script

1 New Member
Hello, I'm a bit new to Perl so I was hoping someone with experience could give me a quick answer.

Question: The following script changes the date from today's date to (today's date+6 months). How do i change that value to 2 or 3 months instead?

Thanks!
Expand|Select|Wrap|Line Numbers
  1. #!/usr/local/bin/perl -w
  2.  
  3. use strict;
  4. use Date::Calc qw( Delta_Days Add_Delta_Days Today Month_to_Text );
  5.  
  6. my $TAC_FILE = "$ENV{HOME}/tacacs/common/user_accounts";
  7.  
  8. my ($year, $month, $day) = Add_Delta_Days(Today(), 30);
  9.  
  10. my $m = substr(Month_to_Text($month),0,3);
  11.  
  12. my $expire_date =  "$m $day $year";
  13.  
  14.  
  15.  
  16. open(TACFILE, "$TAC_FILE") || die "Can't open $TAC_FILE file\n";
  17.  
  18. while(<TACFILE>) {
  19.  
  20.    if (/^\s+member\s+=\s+\S+\s+$/) {
  21.       s/^(\s+)(member\s+=\s+\S+)/$1$2\n$1expires = "$expire_date"/
  22.    }
  23.  
  24.    print $_;
  25. }
  26. close(TACFILE);
  27.  
Sep 16 '08 #1
1 1935
Ganon11
3,652 Recognized Expert Specialist
Not being completely familiar with all the modules used here, it still looks like the Add_Delta_Days function is only adding 30 days to Today(), which is approximately 1 month. You can try changing the value in Add_Delta_Days, or see if there's another function in Date::Calc like Add_Delta_Months.
Sep 16 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
1910
by: Tim Conkling | last post by:
I'm having difficulty tracking down a bug in my program and I'm wondering if it's due to some misuse on my part of new'd objects. Here's the situation. If anyone can shed some light on this, I'd be...
4
19788
by: Jo | last post by:
Is there anyway we can know using JavaScript the Short Date Format used in the Control Panel -> Regional and Language Settings? I know the using the combinations of following we can get the...
8
25358
by: dlx_son | last post by:
Here is the code so far <form name="thisform"> <h3>Enter time to add to or subtract from:</h3> (If not entered, current time will be used)<br> Day: <input name="d1" alt="Day of month"...
6
4829
by: MickG | last post by:
Hi, I am trying to validate these values, this seems to work fine for the phone number and name but I am trying to get the program to fail to submit and set the focus on the date when 2006 is...
4
7484
by: rzhang | last post by:
Hi, We have an Access Application which works fine for most of the users. But there is one user who has the date input problem. When he enter a date field from a form, i.e. 09/03/2004 (Sept....
10
11902
by: John Morgan | last post by:
Does anyone know what parameter should be used instead of Date = 0 for the optional parameter in the following function? Public Function dhAge(ByVal dtmBD As Date, Optional ByVal dtmDate As Date...
5
3147
by: Easystart | last post by:
Hi, Sorry for my English. English is not my native tougue. I am working in MS Access 2000 with a SQLServer 2000 Backend database. MS Access 2000 is my GUI front end that has SQLServer linked...
6
14431
by: rohayre | last post by:
Im a long time java developer and actually have never done anything with java scripting. I'd like to write a short simple script for calculating a date in the future based on today's date and a...
0
7225
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,...
0
7123
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
7495
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5052
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...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3193
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...
0
3181
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1556
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.