On Wed, 12 Jan 2005, Anish Kumar K. wrote:

> I use perl template function to print the values in the html file.
> 
> In that I do a manipulation in percentage.
> 
> Line:
> 
> <td width="20%" height=1 bgcolor="[%BGCOLOR%]" valign="middle" 
> align="left" class="bodytext"><b>[% (browserTotal / browserCount) * 
> 100 %]</b></td>
> 
> i.e (browserTotal / browserCount) * 100 which is a percentage 
> value...Say for example it 35.457565575
> 
> I just wanted it have in two decimal places...Like 35.46...I tried 
> round, ceil , floor and all possible functions it is not 
> working..Please help me in that.

As is usual, it would help to see the Perl code behind the template.

In any case though, your best bet is probably just to pass the template 
a variable -- say, 'browserPercentage', which maps to $browserPercentage 
in your Perl code. 

Going at the problem that way, you can format the data using any Perl 
tools (e.g. sprintf, which is the usual tool for this problem) rather 
than the reduced toolset that your template language provides you:

  $browserPercentage = sprintf("%.2f", ($btotal / $bcount ) * 100);

...and then give that to the template with the other data.



-- 
Chris Devers

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


Reply via email to