Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Duplicating a string?

Reply
Thread Tools

Duplicating a string?

 
 
gao_bolin@voila.fr
Guest
Posts: n/a
 
      06-17-2005
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.

 
Reply With Quote
 
 
 
 
Mark Clements
Guest
Posts: n/a
 
      06-17-2005
On 17 Jun 2005 02:13:55 -0700, http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> 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
 
Reply With Quote
 
 
 
 
Prasanna
Guest
Posts: n/a
 
      06-17-2005
$number_of_times=10; # whatever number of times you want the stuff to
be repeated

$string= "FOO" x $number_of_times;

print " $string";

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.Net Duplicating DB Entries Todd Plambeck ASP .Net 2 08-05-2005 07:55 PM
Duplicating datasheet screens Don ASP .Net 0 02-23-2005 03:09 AM
log4j duplicating appender entries George Jempty Java 2 01-15-2005 06:09 AM
Forms authentication duplicating ReturnURL AC ASP .Net 0 07-27-2004 02:10 PM
Help not duplicating previous matches johkar XML 0 08-08-2003 12:58 AM



Advertisments