in reply to Re: Is There A Better Way?
in thread Is There A Better Way?

And since there's more than one way to do it...

$num = 12; print 0 x (11 - length($num)), $num;

Replies are listed 'Best First'.
Re: Re: Re: Is There A Better Way?
by rob_au (Abbot) on Aug 14, 2002 at 02:01 UTC
    And some more obfuscated ways listed in this thread - Including my own attempt at obscurity ...

    sub a{$_=int$_[0]*10**$_[1]+.5;s;(.{$_[1]})$;\.$1;;chop if substr($_,- +1)eq'.';return$_};
    ... Although I would not use it in production code myself :-)