Found this buried away in the back of my mind. Let’s say you want to create an array with 20 elements, set to the same initial value. You might do this:
my @array = ();
for(my $i = 0; $i <= 19; $i++) {
$array[$i] = "0.00";
}
Or you might recall the very useful repetition operator:
my @array = ("0.00") x 20
As they say, TMTOWTDI – but some ways are better than others.


