Padding a length of string

Brian Morgan <[email protected]>
Newsgroups gmane.comp.lang.perl.fun
Message-ID <[email protected]>
Hello all,
Here is something that I have been playing with, and I am wondering if 
it can be shortened at all.

The script is given a string that is shorter then a MAX length as well 
as a special character. It
then adds onto the end of the string the special character until the 
length of the string is equal
to MAX.

Here is my solution as an example of what I am talking about:
#BEGIN EXAMPLE

$max = $ARGV[0];
$key = $ARGV[1];
$pad_string = $ARGV[2];
@key_chars = split(//, $key);
$count = $#key_chars + 1;
while ($count <= $max){
    $key .= $pad_string;
    $count++;
}
print $key;

#END EXAMPLE

So can anyone out there compress this down? I can't wait to see the results.

Thanks,
Brian
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.