molecules has asked for the wisdom of the Perl Monks concerning the following question:

I just wanted to know before I decided to create one. I tried searching but haven't found one.

UPDATE:
In Perl6 the operator xx will create a list of any number of items that you would like. For example:
use v6; my @array = (1) xx 5;
is the same as
use v6; my @array = (1, 1, 1, 1, 1);
You can achieve the same thing in Perl5 using x (thanks kennethk and ikegami):
#perl5 my @array = (1) x 5;
I previously thought that x only created strings.
  • Comment on Is there a Perl5 module on CPAN that provides a function analogous to the Perl6 list-repeat operator?
  • Select or Download Code

Replies are listed 'Best First'.
Re: Is there a Perl5 module on CPAN that provides a function analogous to the Perl6 list-repeat operator?
by ikegami (Patriarch) on Aug 11, 2010 at 15:28 UTC
    I'm not sure what that operator is, so here are two possibilities.

    If you want multiple copies of the same value,

    ( EXPR ) x $x # Parens required

    If you you want to generate multiple values from the same expression,

    map { EXPR } 1..$x
Re: Is there a Perl5 module on CPAN that provides a function analogous to the Perl6 list-repeat operator?
by kennethk (Abbot) on Aug 11, 2010 at 15:18 UTC