in reply to Re^2: Formatting Input
in thread Formatting Input

<moment>DUH! It just occurred to me that you're probably not taint-checking the user input.</DUH-moment>

That's dangerous; DANGEROUS, I say.

Use taint checking on user input, always! (and using <pre> is not nearly as good a cure for your problem as a variant of advice offered above: s/\n/<br>/m;)

Replies are listed 'Best First'.
Re^4: Formatting Input
by akwe-xavante (Acolyte) on Jun 15, 2012 at 14:16 UTC

    $Contents =~ tr/\n/<br>/ and $Contents =~ s/\n/<br>/ don't work and give an undesirable result, i haven't tried $Contents =~ s/\n/<br>/m though.

    However the <pre> tags give me what i'm looking for but in the wrong text font style, size and color as expected and the text is displayed with its blank lines and the text goes right off the edge of the screen.

    This gives me something i can work with

    I will try using $Contents =~ s/\n/<br>/m when i can on monday to see what it gives me

    Thank you

Re^4: Formatting Input
by akwe-xavante (Acolyte) on Jun 15, 2012 at 15:48 UTC

    Adding the code $Contents =~ s/\n/<br>/m; has no effect at all i'm afraid

    White space and new lines are lost

    Adding the code $Contents =~ s/\n/<br>/m; does have an effect in that looking at the source code printed to the browser on the first newline only <br> is added but not on any other newline after that

    Using the code $Contents =~ s/\n/<br>/mg; works a treat

      Yup.

      My fault for gorfetting the /g.   :)

      However, your post above says:

      "Adding the code $Contents =~ s/\n/<br>/m; has no effect at all i'm afraid"

      but one line later you state the opposite:

      "Adding the code $Contents =~ s/\n/<br>/m; does have an effect in that looking at the source code printed to the browser on the first newline only is added but not on any other newline after that"

      You can't have it both ways!

      You may have noted above (at Re^5: Formatting Input) that I objected to use of pronouns that are "(u)nclear, ambiguous, lacking a clear antecedent.... Please add "posts with mutually contradictory statements" to the list of modes that make good help harder to provide.

      So, please, next time you have a question to post, consider this:
      to help effectively we need to know the details of what you're doing... and the details of what's going wrong (errors messages, warnings, output that isn't what you want and so on). The third para of your latest node pretty much satisfies that, albeit with narrative description rather than samples. But we could have gotten to this apparently satisfactory solution at "Re: Formatting Input" had you provided a clear, complete SOPW.