Luke,
It's impossible to say without knowing what your data looks like (what's the
value being returned by $FORM::F_totalsum)
If you can't rely on your data, you could have a look at this regex. It's in
it's own test suite for you :-).
#!perl -w
use strict;
foreach my $string (" 123.23", "123 ", "123.23", "234.234", " 2 ", " .3
"," 12. ") {
if ($string =~ m/(\d+?\.\d*|\.?\d+)/) {
my $num = $1;
print ">>$num<<\n";
} else {
print "unknown format\n";
}
}
HTH
Rob
"Cool Hand Luke" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Ahoy, hoy.
> I am having problems with this script, it keeps adding 6 blank spaces in
> front of a variable when it calculates it. I can't see why it's doing so.
> The variable in question is the $x_amount. Can anybody see where I'm going
> wrong, or alternately is there a quick way to strip a variable down to
just
> numbers and "."s? Just one line I could add maybe at the end that would
> strip it of these 6 blank spaces?
> Any help is appreciated.
> Thanks,
> Luke
>
> if ($FORM::F_totalsum) {
> @sumvars=split(/,/,$FORM::F_totalsum);
> $x_amount=0;
> foreach $i (@sumvars) {
> if ($i eq "F_subtotal") {
> $x_amount+=$subtotal;
> } elsif ($i eq "F_tax") {
> $x_amount+=$tax;
> } elsif ($var_set{$i}) {
> $x_amount+=$req->param($i);
> } else {
> &err("$i is not defined");
> }
> }
> $x_amount=¤cy($x_amount);
> }
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]