Well, the code provided should not run (have not tried it myself, but do not see how you can avoid a syntax error). The most obvious reason for the foreach loop "not to be called" is if the list is empty. So the first thing to look at is how you are creating that list. And based on that horrible first line in your example, it's not hard to imagine you are accidentally passing in an empty list/array. Add "use strict; use warnings; " at the top of your program and resolve all of the issues they spit out. Will likely take care of your problem here along the way.
Elda Taluta; Sarks Sark; Ark Arks