Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
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 surveying the Monastery: (4)
As of 2024-04-20 04:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found