Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Plain Text Linebreak problem within a CGI script

Reply
Thread Tools

Plain Text Linebreak problem within a CGI script

 
 
xhoster@gmail.com
Guest
Posts: n/a
 
      05-24-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) 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
 
Reply With Quote
 
 
 
 
gundalav@gmail.com
Guest
Posts: n/a
 
      05-24-2006
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

 
Reply With Quote
 
 
 
 
David Squire
Guest
Posts: n/a
 
      05-24-2006
(E-Mail Removed) 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
>

 
Reply With Quote
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      05-24-2006
(E-Mail Removed) 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
what's wrong calling a Perl/CGI script in Perl/CGI script under Tomcat server? kath Perl Misc 4 04-09-2007 09:21 PM
Perl CGI returning plain text HTML code ich_bin_Ingenieur Perl Misc 4 03-27-2007 05:43 AM
Linebreak problem on the interactive interpreter Win2k Jonas Galvez Python 0 02-20-2004 07:09 AM
Re: CGI script is in plain text BMA TRADING Python 1 07-04-2003 03:37 PM
CGI script is in plain text A Python 0 07-03-2003 08:39 PM



Advertisments