in reply to Why is file being slurped in instead of line by line?
It's because you're undefing $/. That's what the perl runtime uses to determine the line-break character (or string). (Well, technically, line-end string, but let's not get carried away.) Comment out that line, and you'll get what you expect.
If you need it for other things, you should localise your changes - see local. e.g.:
{ # I want to slurp here. local $/; # sluuuuuuuurrrrrp... } # $/ is back to normal here.
In Section
Seekers of Perl Wisdom