Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

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?

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-06-20 05:10 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.