in reply to Uniformly Populating an Array with Elements of Another Array
The map & modulus operators are your friends for a job like this.
#!/usr/bin/perl -w use strict; my @elems = ("x", "y", "z"); my @tobepopulated; push @tobepopulated, "foo" for (1..10); my $cnt=0; my @new_array = map { $_ . "-" . $elems[$cnt++ % @elems] } @tobepopula +ted; print join "\n", @new_array;
...roboticus
|
|---|