JeeBee wrote:
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
Why do you use ?: for all fields?
Are all fields optional?
If so, what would be present in the file if a field is blank?
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/