Duplicating a string?

Discussion in 'Perl Misc' started by gao_bolin@voila.fr, Jun 17, 2005.

  1. Guest

    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.
    , Jun 17, 2005
    #1
    1. Advertising

  2. On 17 Jun 2005 02:13:55 -0700, 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
    Mark Clements, Jun 17, 2005
    #2
    1. Advertising

  3. Prasanna Guest

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

    $string= "FOO" x $number_of_times;

    print " $string";
    Prasanna, Jun 17, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. AC
    Replies:
    0
    Views:
    503
  2. Don

    Duplicating datasheet screens

    Don, Feb 23, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    343
  3. Todd Plambeck

    ASP.Net Duplicating DB Entries

    Todd Plambeck, Aug 5, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    482
  4. CiTro
    Replies:
    3
    Views:
    231
    Vincent
    Jun 18, 2009
  5. Adam Akhtar

    duplicating characters in a string

    Adam Akhtar, Mar 6, 2008, in forum: Ruby
    Replies:
    29
    Views:
    229
    Paul Brannan
    Mar 12, 2008
Loading...

Share This Page