Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

How to make a variable in a single line

by auhakim (Novice)
on Jun 05, 2013 at 11:35 UTC ( [id://1037189]=perlquestion: print w/replies, xml ) Need Help??

auhakim has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks, I have a data that stored in the database, and it stored in different line

it stored like this
<p>sdfh htr5htrh&nbsp; ken#h</p> <p>Zeile1<br />Zeile2Zeile3<br /></p>

It stored with the line breaks that similar with the line breaks that caused by enter button, not the br tag. Is there any way to delete the line breaks that caused by enter button?

any help will be appreciated

Replies are listed 'Best First'.
Re: How to make a variable in a single line (remove newlines)
by Anonymous Monk on Jun 05, 2013 at 11:43 UTC

    line breaks that caused by enter button?

    You mean remove newlines?  s{[\r\n]+}{}g

      chomp()?

      or better yet,
      local $/;

      For more on $/... perlvar

        chomp doesn't remove newlines, it chomps
Re: How to make a variable in a single line
by rovf (Priest) on Jun 05, 2013 at 12:30 UTC

    $your_variable_containing_newlines =~ tr/\n\r//d;
    UPDATE: typo corrected.

    -- 
    Ronald Fischer <ynnor@mm.st>
      What is \d?

       s{ \R+ }{}gx aka  s{[\x{000A}\x{000C}\x{000D}\x{0085}\x{2028}\x{2029}]+}{}g

        Thanks, I corrected my posting.

        -- 
        Ronald Fischer <ynnor@mm.st>

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2024-03-29 01:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found