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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

take time on file

Status
Not open for further replies.

Yarka

Technical User
Joined
Jan 14, 2007
Messages
192
Location
ES
Hi,
I have a large file with lines of style as and I need to extract the time:
...
58702 a ... 21:13:00,236 ... b2 0EP:D7 33 1,0 t2.3.22 aco 55.33.kk

58 cc ... 21:33:22,236 ... b2f 00:02 0EP:D7 555 1,0 t2.3.22 aco 55.33.kk

...

689 a ... 21:33:22,236 ... 00:13 b1 00:02 0EP:D7 969 1,0 t2.3.22 aco 55.33.kk

...

58702 aww ... 21:33:22,236 ... 00:13 b2 00:02 0EP:D7 969 1,0 t2.3.22 aco 55.33.kss

...

My pattern is t2.3.22 aco, so I need to extract all lines that have this pattern. Next I need to have the time. I am trying do something as:

if(/^(\d+)\t([\t]+)\t2.3.22.*?$/){
$s = $1 ; $t1 = $2 ; $t1 =~ s/,/./ ;
if($t1 =~ /(\d+):(\d+):([\d.]+)/) {
$t1 = $1 * 3600 + $2 * 60 + $3 ;
....
}

but, it doesn't work fine. This isn't correct. Can anybody help me?

Thanks.
 
didn't you already post this same question?

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
It doesn't same question. The question is how can I take the time with help the pattern. If the time is before pattern I know how I can extract:
if(/^(\d+)\t([^\t]+)\t2.3.22.*?$/)
and this work fine, but I don't know if it is in middle.
Sorry, but I am beginner in Perl.
 
Yarka,

Next time just continue in the same thread that you originally started for the project instead of essentially spamming the forum. This helps us to avoid duplicating effort, and it also helps you by letting people who have helped you before to get notices that you are continuing to work on the same problem or variations.

You can find your own threads from this link:

- Miller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top