Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Why is file being slurped in instead of line by line?

by Tanktalus (Canon)
on Aug 26, 2006 at 16:31 UTC ( #569813=note: print w/replies, xml ) Need Help??


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.

Replies are listed 'Best First'.
Re^2: Why is file being slurped in instead of line by line?
by Grey Fox (Chaplain) on Aug 26, 2006 at 16:36 UTC
    Thanks; That's what I get for stealing code from something else I had done where I wanted to get rid of the line feed.
    I had a teacher once who used to say. If you can't find something in 5 minutes it is probably a stupid mistake (ie a missing ; or something).
    -- Grey Fox
    Perl - Hours to learn lifetime to master.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://569813]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2022-10-05 12:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (23 votes). Check out past polls.

    Notices?