Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: switching default line terminator?

by CountOrlok (Friar)
on Mar 21, 2006 at 16:07 UTC ( [id://538210]=note: print w/replies, xml ) Need Help??


in reply to switching default line terminator?

Try this:
#!/usr/bin/perl use strict; doStuff(); # no need for & foo(); sub doStuff { # want to read the file as a single string.... local $/; # if you don't set it to anything, it is undefined open TMP, "<somefile.txt"; my $file = <TMP>; # $file since you are putting the whole file into + a scalar, not a list close TMP; # do more stuff with that file... } sub foo { ## here i would want to read the file line-by-line open TMP, "<otherfile.txt"; my @file = <TMP>; close TMP; }
-imran

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-18 04:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found