RE: [ILUG] OT: Formatting Perl output on Web Page?

From: adam beecher (adam at domain iewebs.com)
Date: Fri 19 May 2000 - 12:22:19 IST


http://www.perl.com/pub/doc/manual/html/pod/perlfunc/sprintf.html
http://www.perl.com/pub/doc/manual/html/pod/perlfunc/printf.html

adam

> -----Original Message-----
> From: ilug-admin at domain linux.ie [mailto:ilug-admin at domain linux.ie]On Behalf Of
> Cormac McClean
> Sent: 19 May 2000 12:42
> To: ilug at domain linux.ie
> Subject: [ILUG] OT: Formatting Perl output on Web Page?
>
>
> Hi,
>
> This is probably a RTFM question, and I am checking, but no joy.
> I also have 2 books on Perl but I loaned these and am (temporarily)
> bereft of their wisdom. (Question is possibly also OT).
>
> I am using Perl and Apache on Linux to read data from text files and
> output the data into a HTML table. (Next step will be to use MySQL
> to store the data). My question is this: how do I curtail the amount
> of decimals being displayed from a decimal scalar, e.g. to get the
> percentage attendance based on classess attened / total classes * 100:
> $att_pc = $att / $total * 100;
> when I display this using a print statement I get 12 decimal places,
> which looks a bit silly:
> print "<TD align=center>$att_pc</TD>";
>
> Is there a Perl equivalent to the C %.2f to format output to 2 decimal
> places?
>
> Apologies for the OT nature of this question.
>
> Regards,
> Cormac.
>
> --
> Irish Linux Users' Group: ilug at domain linux.ie
> http://www.linux.ie/mailman/listinfo/ilug for (un)subscription information.
> List maintainer: listmaster at domain linux.ie
>



This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:06:13 GMT