Because I'm trying to match this regular expression a lot of times, that 
could very well be the point to improve. I can imagine this is the 
slowest part of the script:

my $exp = "nan|-?inf|[0-9\.e\+\-]+";
my $stat_pat =
   "(?:\\s+($exp))(?:\\s+($exp))" . # $1 number of samples, $2 minimum
   "(?:\\s+($exp))(?:\\s+($exp))" . # $3 maximum, $4 sum
   "(?:\\s+($exp))(?:\\s+($exp))" . # $5 average, $6 variance
   "(?:\\s+($exp))(?:\\s+($exp))";  # $7 skewness, $8 kurtosis

Which I'm using like this many times:

foreach my $stat_key (@stat_var_keys) {
  if($line =~ m/^\s*$stat_key$stat_pat/) {
        # $6 == "variance"
        $map{"var_$stat_key"} = $6;
  }
}

Can this regular expression be changed to do the same a be a lot faster?

Thanks in advance,
JeeBee.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to