Plain Text Linebreak problem within a CGI script

Discussion in 'Perl Misc' started by xhoster@gmail.com, May 24, 2006.

  1. Guest

    wrote:
    > Dear expert,
    >
    > Why my text under END_OF_TEXT doesn't
    > appear with line break (i.e. in browser it should
    > appear in 3 lines)


    Because that is the way that HTML works. Figure out the HTML
    you need to use to do what you want to do (for example, with <br> or <p>),
    then print *that* HTML.

    Xho

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
    , May 24, 2006
    #1
    1. Advertising

  2. Guest

    Dear expert,

    Why my text under END_OF_TEXT doesn't
    appear with line break (i.e. in browser it should
    appear in 3 lines) as shown in this script verbatim:

    __BEGIN__

    use CGI qw:)standard);

    print header,
    start_html(
    -title => "Some Long Text",
    -style => { -src => './css_scripts/my.css' },
    ),
    h1("Some long text");

    print <<END_OF_TEXT;

    foo bar
    foo bar
    foo bar

    END_OF_TEXT

    __END__

    It appears as one line like this:

    foo bar foo bar foo bar

    What's wrong with my script above?

    --
    Regards,
    Gundala Viswanath
    , May 24, 2006
    #2
    1. Advertising

  3. David Squire Guest

    wrote:
    > Dear expert,
    >
    > Why my text under END_OF_TEXT doesn't
    > appear with line break (i.e. in browser it should
    > appear in 3 lines)


    This is an HTML question, not a Perl question. You are in the wrong place.

    The reason is that newline characters do not indicate line-breaks in
    HTML. The HTML element <BR> (or <BR/>) does. See http://www.w3.org/TR/html4/

    DS


    as shown in this script verbatim:
    >
    > __BEGIN__
    >
    > use CGI qw:)standard);
    >
    > print header,
    > start_html(
    > -title => "Some Long Text",
    > -style => { -src => './css_scripts/my.css' },
    > ),
    > h1("Some long text");
    >
    > print <<END_OF_TEXT;
    >
    > foo bar
    > foo bar
    > foo bar
    >
    > END_OF_TEXT
    >
    > __END__
    >
    > It appears as one line like this:
    >
    > foo bar foo bar foo bar
    >
    > What's wrong with my script above?


    Nothing. It is fine, and the browser is correctly displaying the HTML
    you provided.

    >
    > --
    > Regards,
    > Gundala Viswanath
    >
    David Squire, May 24, 2006
    #3
  4. wrote:
    > Why my text under END_OF_TEXT doesn't
    > appear with line break (i.e. in browser it should
    > appear in 3 lines)


    <snip>

    > print <<END_OF_TEXT;


    One way to display plain text in an HTML document is to use the <pre>
    element, in this case:

    print pre(<<END_OF_TEXT);

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Hjalmarsson, May 24, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. S
    Replies:
    5
    Views:
    9,922
  2. A
    Replies:
    0
    Views:
    281
  3. BMA TRADING

    Re: CGI script is in plain text

    BMA TRADING, Jul 4, 2003, in forum: Python
    Replies:
    1
    Views:
    509
    Alan Kennedy
    Jul 4, 2003
  4. Jonas Galvez
    Replies:
    0
    Views:
    278
    Jonas Galvez
    Feb 20, 2004
  5. ich_bin_Ingenieur

    Perl CGI returning plain text HTML code

    ich_bin_Ingenieur, Mar 23, 2007, in forum: Perl Misc
    Replies:
    4
    Views:
    521
Loading...

Share This Page