Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems in dates and time additions

Status
Not open for further replies.

survivor312

Programmer
Dec 18, 2011
1
US
Hi,

I have 3 files (these are the log files of the system). These files have date formate like this (Dec 5 09:02:01).
I need to read these files from from the first date(Dec 5 09:02:01) till the last date (Dec 17 17:34:02) in the file. Then i have to search a word between the time difference of one minute and i have to count that how many times that word is present between these two time period.

For example :
Start time EndTime Number of times word found.
Dec 5 09:02:01 Dec 5 09:03:00 10 (First entry)

Dec 5 09:03:01 Dec 5 09:03:00 5 (second entry)

Dec 5 09:04:01 Dec 5 09:04:00 3 (third entry


and so on till the last entry of the date (Dec 17 17:34:02)

How i can handle these dates. I have read about the Time::Local but that did not solve my problem.
I will be very thankful for any help.
 
Time::Local is the way to go. With [tt]timelocal()[/tt] you get a [tt]time[/tt] value that you can easily manipulate, test for time periods, etc.
[tt]timelocal()[/tt] must be supplied with a list of time quantities that you can extract from your dates with [tt]split[/tt], except for the year, that I assume is known from elsewhere. Month 3 letter names can be transformed into a number by creating a hash:
[tt]%months=('Jan',0,'Feb',1,...);[/tt]
(be careful as this is case sensitive).
However you didn't tell us of what you've done so far.

Franco
: Online engineering calculations
: Magnetic brakes for fun rides
: Air bearing pads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top