# infobot copyright (C) kevin lenzo 1997-98
#
-if (&IsParam("useStrict")) { use strict; }
+use strict;
+
+use vars qw($message);
my %digits = (
"first", "1",
if (($locMsg =~ /^\s*[-\d*+\s()\/^\.\|\&\*\!]+\s*$/)
&& ($locMsg !~ /^\s*\(?\d+\.?\d*\)?\s*$/)
&& ($locMsg !~ /^\s*$/)
- && ($locMsg !~ /^\s*[( )]+\s*$/))
- {
+ && ($locMsg !~ /^\s*[( )]+\s*$/)
+ && ($locMsg =~ /\d+/)
+ ) {
+ $locMsg =~ s/([0-9]+\.[0-9]+(\.[0-9]+)+)/"$1"/g;
$locMsg = eval($locMsg);
if (defined $locMsg and $locMsg =~ /^[-+\de\.]+$/) {
$locMsg = sprintf("%1.12f", $locMsg);
$locMsg =~ s/\.?0+$//;
- if (length($locMsg) > 30) {
+ if (length $locMsg > 30) {
$locMsg = "a number with quite a few digits...";
}
} else {
if (defined $locMsg) {
&DEBUG("math: locMsg => '$locMsg'... FIXME");
} else {
- $locMsg = "undefined";
+ &status("math: could not really compute.");
+ $locMsg = "";
}
}
} else {
$locMsg = "";
}
- if ($locMsg ne $message) {
+ if (defined $locMsg and $locMsg ne $message) {
+ # success.
return $locMsg;
} else {
+ # no match.
return '';
}
}