in reply to Re^3: File lines being treated as one.
in thread File lines being treated as one.

I can't see any different between you first code and second with sub, perhaps the problem is how you call your sub?
And I have to repeat GrandFather: make sure you are using strictures: use strict; use warnings;