DB<126> @arr = (("A") x 2, ("T") x 2, ("C") x 3, ("G") x 3); => ("A", "A", "T", "T", "C", "C", "C", "G", "G", "G")
see perlop#Multiplicative-Operators "repetition operator" for details
Binary "x" is the repetition operator. In scalar context or if the left operand is not enclosed in parentheses, it returns a string consisting of the left operand repeated the number of times specified by the right operand. In list context, if the left operand is enclosed in parentheses or is a list formed by "qw/STRING/", it repeats the list. If the right operand is zero or negative, it returns an empty string or an empty list, depending on the context.
but I have to admit it sounds confusing ... :)
hmm should maybe be rephrased:
DB<129> $arr = ("G") x 3; => "GGG"
always a string in scalar context!
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
In reply to Re: Loading multiple identical variables in array with multiplication variable
by LanX
in thread Loading multiple identical variables in array with multiplication variable
by Jeri
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |