in reply to Two loops
Thus lines is a scalar value, there's only one of them, doesn't the outside loop execute only once?
At least, when I try running: perl -e 'foreach (5) { print "Hello\n" }' I only get one loop.