Re: Padding a length of string

Yanick <[email protected]>
Newsgroups gmane.comp.lang.perl.fun
Message-ID <[email protected]>
On Mon, Apr 19, 2004 at 03:05:23PM -0400, Brian Morgan wrote:
> 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.

	perl -e'print$_=$ARGV[1],(pop)x(shift()-tr|||c)' 10 abc d  ?

Joy,
`/anick
-- 
Never do anything against conscience even if the state demands it.
- Albert Einstein
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.