my @fragments; push @lines, sprintf "Percent\t"; for (...) { ... push @fragments, sprintf ...; } push @lines, join '', @fragments;