[ale] Convert to float

J.M. Taylor jtaylor at onlinea.com
Mon Apr 5 16:01:11 EDT 2004


Chris,

By "running total" is it safe to assume you mean:
$total = 0;
foreach (row from mysql)
{ 
  $total = $total + row[i][number];
}

? What specifically is your perl not doing that you think it ought?  Perl 
should, afaik, automagically type things but if it doesn't, you should be 
able to cast it with something like $var = (float)$var  ...I've not 
done perl in ages so I could be wrong but I'd be willing to bet it's 
something similar.  http://www.perldoc.com/perl5.8.0/pod/perlfaq4.html 
should help more than I can.

Good luck
jenn

On 5 Apr 2004, Chris Fowler wrote:

> I'm pulling a number in the format of 00.00 from a database in MySQL. 
> It is of type float there.  I need to convert to a float in perl so I
> can keep a running total.
> 
> Thanks,
> Chris

-- 
Jenn Taylor
jtaylor at onlinea.com

------------------------------------------------------------------------
Obviously, a man's judgement cannot be better than the information on which he
has based it.  Give him the truth and he may still go wrong when he has
the chance to be right, but give him no news or present him only with distorted
and incomplete data, with ignorant, sloppy or biased reporting, with propaganda
and deliberate falsehoods, and you destroy his whole reasoning processes, and
make him something less than a man.
-- Arthur Hays Sulzberger




More information about the Ale mailing list