Sams Teach Yourself Perl in 24 Hours (3rd Edition)

 <  Day Day Up  >  

Q&A

Q1:

The output of the Interest program looks sloppy . How do I control how many digits are displayed?

A1:

The easiest way to control the number of decimal digits is to use the printf function, which is covered in Hour 9, "More Functions and Operators."

Q2:

Does Perl have a function for rounding?

A2:

The printf function usually does what you want for rounding when displaying numbers . If you really need the round function, check out the POSIX module, which has this function and many more.

Q3:

How large (or small) of a number will Perl let me manipulate?

A3:
 <  Day Day Up  >  

Категории