Duplicating a string?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

This is a very basic question: is there a simple way to just duplicate
a string? Say I want to have a string with 10 "a"s or duplicate 3 times
'FOO' in the same string. There must be a better way than creating an
array then 'join'ing it...



Re: Duplicating a string?

$number_of_times=10; # whatever number of times you want the stuff to
be repeated
$string= "FOO" x $number_of_times;

print " $string";

Re: Duplicating a string?

On 17 Jun 2005 02:13:55 -0700, gao_bolin@voila.fr wrote:

Quoted text here. Click to load it
perldoc perlop

print "test" x 42;

perldoc is your friend.


Site Timeline