my @array = ("foo", "bar", "baz");
my $total_length = 6;
push @array, (0) x ($total_length - @array);
From perldoc:
Binary "x" is the repetition operator. In scalar context or if the left operand is not enclosed in parentheses, it returns a string consisting of the left operand repeated the number of times specified by the right operand. In list context, if the left operand is enclosed in parentheses or is a list formed by qw/STRING/, it repeats the list. If the right operand is zero or negative, it returns an empty string or an empty list, depending on the context.
As a sub with the specified usage:
sub pad_with_zeroes { my $n = pop; return ( @_, (0) x ($n-@_) ) }