in reply to printf & sprintf: variable number formats

A simple concat works,
$int = 5; printf "%0" . $int . "i", $myInt;
it just isn't as pretty. But it also works with constants
use constant COLWIDTH => 5; $int = 5; printf "%0" . COLWIDTH . "i", $myInt;

--

flounder

Replies are listed 'Best First'.
Re: Re: printf & sprintf: variable number formats
by duff (Parson) on Jan 06, 2004 at 19:41 UTC

    Good point. I should probably have mentioned that very thing about printf "%0*i", $int, $myint; too