in reply to Regular expression
I was asking about efficiency between split and using a regx: Here is the stuff: Using split: while(<DATA>) { ($time,$date,$data1,$data2) = (split)[1,2,6,7]; print "$time $date $data1 $data2", "\n"; } the code took:26 wallclock secs ( 2.17 usr + 0.55 sys = 2.72 CPU) Using an REGX: while(<DATA>) { /^(\d+) (\d\d:\d\d:\d\d) (\d\d-\w+-\d{4}) (\d+) (\d+\s+\d+) (\d.\d*E +[+-]\d+) (\d.\d*E[+-]\d+)/; print "$2 $3 $6 $7\n"; } the code took:25 wallclock secs ( 1.98 usr + 0.73 sys = 2.71 CPU) Much of a muchness really. Regards, Stacy.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Regular expression
by Anonymous Monk on May 01, 2001 at 17:54 UTC |