my $fmt = $FMT_DNA[$i++ % @FMT_DNA];
- Get the remainder when $i is divided by the number of elements in @FMT_DNA and put it in a temp variable.
- Increment $i by 1.
- Get the element in @FMT_DNA with an index of the temp variable and put it in $fmt.
What this is doing is treating @FMT_DNA as a circular list - a list that will wrap around to the beginning when it runs out of elements. So, if it was 3 elements, it would do element 0, element 1, element 2, element 0, element 1, etc.
------ We are the carpenters and bricklayers of the Information Age. The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6 Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified. |