printf("A float: %12" . ($root_beer ? ".4f" : "s") . $/, ($root_beer || '')); #### if ($root_beer) { printf("A float: %12.4f$/", $root_beer); } else { printf("A float: %12s$/", ''); } #### printf("A float: %12s$/", $root_beer ? sprintf("%12.4f",$root_beer) : ''); #### my $root_beer_str = $root_beer || ''; # change 0 to blank. $root_beer_str &&= sprintf("%12.4f", $root_beer); printf("A float: %12s$/", $root_beer_str); #### printf("A float: %12s$/", ($root_beer || '') && sprintf("%12.4f", $root_beer));