in reply to Two loops

The outside loop,
foreach ( $lines ) {
is calculated from:
$lines =scalar@data/5;
which, when re-written probably looks like this:
$lines = scalar( @data ) / 5;

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.