I have a $number variable, and a $string, what is the fastest way to create a list of size $number that holds $string in each list entry?Why by using the repetition operator in a list context of course
See. the Multiplicative Operators section of perlop for more info on the repetition operator.my $number = 4; my $string = 'hello'; my @list = ($string) x $number; print @list; __output__ hellohellohellohello
_________
broquaint
In reply to Re: Array population
by broquaint
in thread Array population
by hotshot
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |