Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Re: Re: slurping into scalars

by dingus (Friar)
on Dec 16, 2002 at 11:11 UTC ( [id://220169]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: slurping into scalars
in thread slurping into scalars

Is it possible to alter this so every new-line is printed to a new-line?? for some reason this merges all lines together.
$_ = join("\n", <FILE>);
Adds a second \n to every line. This may be what you are looking for. Seems a bit odd though.

I have done this kind of thing (with some differences) when doing quick and dirty text->html output. Say you want to put <p> tags when you have blank lines but otherwise leave the text untouched then the folowing code works:

do {local $/ = $/.$/;print join('<p>', <FILE>);};

Dingus


Enter any 47-digit prime number to continue.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2024-03-29 09:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found