re: Padding a length of string
Quantum Mechanic <[email protected]>
| Newsgroups | gmane.comp.lang.perl.fun |
|---|---|
| Message-ID | <[email protected]> |
Brian Morgan [[email protected]] wrote: > $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; You had part of the solution in your subject [length]: $key .= $pad_string x ($max - length($key)); print $key; ===== ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Quantum Mechanics: The dreams stuff is made of __________________________________ Do you Yahoo!? Yahoo! Photos: High-quality 4x6 digital prints for 25¢ http://photos.yahoo.com/ph/print_splash