in reply to perl newbie question

Sure ... but why wouldn't you want to use s/printf?

At the risk of answering a homework question:

$newtemp =int(100*((($temp-32)*5)/9))/100;

-derby

Replies are listed 'Best First'.
Re^2: perl newbie question
by dsheroh (Monsignor) on Jan 06, 2008 at 17:06 UTC
    Note that int always rounds towards zero. To get it to round (more) correctly:
    $newtemp =100*((($temp-32)*5)/9); if ($newtemp > 0) { $newtemp = int($newtemp + 0.5)/100; } else { $newtemp = int($newtemp - 0.5)/100; }
    But (s)printf really is the right solution here...