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
Apologies for the OT nature of this question.
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!