in reply to anyway to combine these two steps?

Actually you want $num = sprintf("%02d", $num % 100); to avoid Y2K errors.