in reply to Placement of "my"

It depends on your requirement. If you don't want $var to be visible outside, then declare inside the loop.

--Lakshmanan G.

The great pleasure in my life is doing what people say you cannot do.