Get the time difference between two consecutive line in UNIX perl script

Hi All :o,

I have some log files which contains these informations:

2013-04-24 09:11:34.018 INFO XXXXXXXXXXXX
2013-04-24 09:11:34.029 INFO YYYYYYYYYYYY
2013-04-24 09:11:34.039 INFO ZZZZZZZZZZZZZZZ
2013-04-24 09:12:21.295 INFO TTTTTTTTTTTTTTT
2013-04-24 09:12:21.489 INFO JJJJJJJJJJJJJJJJJJJJJJJJ
.........................................................................................

Note: 1.) "...." means continue the log file
2.) TTT,XX,JJJJ are some other information which i can not paste here.

I have written one perl script which can calculate and display my test print statements like:

sharique test..time per line = 02:16:06
sharique test..total sec per line = 8160

sharique test..time per line = 02:16:51
sharique test..total sec per line = 8160

sharique test..time per line = 02:21:10
sharique test..total sec per line = 8460

sharique test..time per line = 02:26:40
sharique test..total sec per line = 8760
.........................................................................................
.........................................................................................

Now i need to calculate the total second difference b/w each lines and print into the log file, something like this:

sharique test..time per line = 02:16:06
sharique test..total sec per line = 8160
sharique test..time difference b/w lines = 20

sharique test..time per line = 02:16:51
sharique test..total sec per line = 8160
sharique test..time difference b/w lines = 0

sharique test..time per line = 02:21:10
sharique test..total sec per line = 8460
sharique test..time difference b/w lines = 300

sharique test..time per line = 02:26:40
sharique test..total sec per line = 8760
sharique test..time difference b/w lines = 300
.........................................................................................
.........................................................................................

Can anyone please help me on this ASAP.

A Great Thanks,
Sharique............:slight_smile:

Please do not use words like "ASAP" if you require help..

Everyone at the UNIX and Linux Forums gives their best effort to reply to all questions in a timely manner. For this reason, posting questions with subjects like "Urgent!" or "Emergency" and demanding a fast reply are not permitted in the regular forums.

For members who want a higher visibility to their questions, we suggest you post in the Emergency UNIX and Linux Support Forum. This forum is given a higher priority than our regular forums.

Posting a new question in the Emergency UNIX and Linux Support Forum requires forum Bits. We monitor this forum to help people with emergencies, but we do not not guarantee response time or best answers. However, we will treat your post with a higher priority and give our best efforts to help you.

Thank you.

The UNIX and Linux Forums

I'd like to add that you should always use code tags. It's a total waste of time for the hard-working administrators to clean up posts that lack them. They've got a lot better things to do. It seems like your first post. As scrutinizer mentioned, you can build up bits by posting. Many thousands of bits can be earned. You can get incredibly good answers here and learn a lot. There are many uses for the bits as they pile up. But you can also get infractions if you break the rules. Nobody wants that to happen. :mad: So make sure you use those code tags religiously, and be patient with the gurus as they ponder your questions.

sorry abt all the issues..yeah..its my first post. :slight_smile: on this forum.