473,666 Members | 1,989 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 1940
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_Month s.
Sep 16 '08 #2

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

Similar topics

6
1918
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 much obliged. I have a simple class that looks something like this (this is a rather abbreviated version): class TileAttributes {
4
19801
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 Locale Long Name format toString() toLocaleString() toLocaleDateString()
8
25378
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" size=3> Month: <input name="m1" alt="Month" size=3> Year: <input name="y1" alt="Year" size=5> (4 digits for year, e.g.
6
4840
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 selected and submitted. Thanks in advance for any help.
4
7493
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. 3, 2004), the value always gets flipped into 03/09/2004(Mar 9, 2004) as soon as the cursor leaves that date field. When he enters 09/24/2004, the value doesn't get flipped. My discovery is that any value in between '/' under 12 will be flipped.
10
11945
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 = 0) As Short
5
3161
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 tables in it. One of my forms has two TEXT BOX controls formated as Short Date. The form is binded to a linked table. The linked tables has about 7 records and one of the control is binded to a table field. These two controls displays the date...
6
14442
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 letter. Can I use javascripting to create a webpage to allow a user to enter a letter and then click a button to find a future calendar date? I'm just not sure how much user interaction scripting allows. Does java scripting allow buttons, textfields...
0
8356
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
8871
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...
1
8552
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
8640
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7387
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
5666
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
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
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2773
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 we have to send another system

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.