in reply to Blankety-Blank Blanks and Zeros, etc.

One thought:
print +("A float: ", $root_beer? sprintf("%12.4f", $root_beer) : $"x12, $/);
(And that's the first time I've seen someone stick $/ inside a double-quoted literal. I use $/ a lot, but I use \n if I'm already in the string literal.)

--
[ e d @ h a l l e y . c c ]

Replies are listed 'Best First'.
Re^2: Blankety-Blank Blanks and Zeros, etc.
by duff (Parson) on Aug 26, 2005 at 19:17 UTC

    Why not just switch out the format?

    printf +($root_beer ? "%12.4f" : " "x12)."\n", $root_beer;
    That's what I'd do if I didn't care too much about maintainability.

    Of course, the correct way to do it is something like this:

    if ($root_beer) { printf "%12.4f\n", $root_beer } else { print " "x12 . "\n"; }
    Or any way that you consider more readable. Where "readable" means that you can look at it 6 months later without thinking, "what the hell was I thinking when I wrote this?" :-)