Duplicating a string?

G

gao_bolin

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...

Thanks!

B.
 
M

Mark Clements

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...
perldoc perlop

print "test" x 42;

perldoc is your friend.

Mark
 
P

Prasanna

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

$string= "FOO" x $number_of_times;

print " $string";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top