my $format = "Hello there %3d!"; my @data = (123); if (defined $pi) # if we've calculated pi ... { $format .= " %5.1f"; push @data, $pi; } printf "$format\n", @data;