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>