469,309 Members | 2,792 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Please Help for perl Script

HI Guru,
I am newbabe in perl, Could you please help me out.
I am having a file withComma (,) seprater data records. Like below 2 lines
01/09/2008 00:00:00,+99001000000001,http://wap.mysite.com/news/world/ind...00-Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; PPC; 240x320)

01/09/2008 00:00:02,+99002000000002,http://wap.mysite.com/news/business/....xx,LGE-CX5450 UP.Browser/6.2.2.3.d.1.103 (GUI) MMP/2.0

--------------------------------------
I would like to replace first filed of the line date (01/09/2008) with adding 5 month in existing date and rest of the data should be same.using perl scripts

Input File:
01/09/2008 00:00:00,+99001000000001,http://wap.mysite.com/news/world/ind...00-Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; PPC; 240x320)

Result file I need:
01/02/2009 00:00:00,+99001000000001,http://wap.mysite.com/news/world/ind...00-Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; PPC; 240x320)


Note: date in Input file: 01/09/2008 changed to 01/02/2009 means that scripts should add 5 month into exsiting date in file.

Looking for your response asap.

Thanks
Max
Mar 24 '09 #1
2 1620
gpraghuram
1,275 Expert 1GB
To add 5 months to a date you can make use of time functions.
You can first get the tick count for the date in the input.
Add 30 * 5* 86400
then convert the tick back to normal date.

I think there is a date calculator also in unix , which i have used some time back(but i dont remember the command name)

Raghu
Mar 27 '09 #2
numberwhun
3,503 Expert Mod 2GB
@maxman1

To do this, you are going to have to disect each line and pull out the date, then use something like the date::calc module from cpan in order to do the modification.

Why not give this a try and then post your code here if you get stuck.

Regards,

Jeff
Mar 27 '09 #3

Post your reply

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

Similar topics

2 posts views Thread by Sandman | last post: by
1 post views Thread by sam | last post: by
1 post views Thread by Julia Bell | last post: by
9 posts views Thread by Martin Foster | last post: by
5 posts views Thread by Louis | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.