473,385 Members | 2,044 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,385 software developers and data experts.

Modifying Date value in this short script

1
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 1929
Ganon11
3,652 Expert 2GB
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
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
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
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
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
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
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
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
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
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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...

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.