Re: Help with Stupid question



On 7/15/06, Ralph H. Stoos Jr. <rstoos@xxxxxxxxxxxxxxxx> wrote:

I want to know if / how the $buf/25400 part can
be formatted to be a number with only two or three decimal places.

In Perl, that kind of formatting is generally done with printf or its
related function sprintf. Where sprintf is a function which returns a
formatted string, printf goes a step further and prints the string.
They're documented in perlfunc, but this example may be all you need:

my $result = sprintf "%.3f", $buf/25400;

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training
.



Relevant Pages