Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Text output is on one line

by ph0enix (Friar)
on Dec 10, 2002 at 19:45 UTC ( [id://218881]=note: print w/replies, xml ) Need Help??


in reply to Text output is on one line

If you undefine line separator (undef $/;) than whole file will be red as one line ($bookfile_contents = <FILE>;)

If you want to read from file line by line than use

if(-f "$bookfile"){ open(FILE, "+<$bookfile") || &debug("Oops, I cannot read the bookfile $bookfile: $!"); if($opsys eq "unix"){flock(FILE, 2);} else{binmode(FILE);} while (my $line = <FILE>) { # do something with one line } }

What does mean $/ = "tr/\n /";? Your line will end with following text? I don't think so.

tr/ /

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (9)
As of 2025-06-25 07:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.