my $fill = scalar @lines % 3; while ($fill-- > 0) { push @lines, " "; }