develooper Front page | perl.beginners | Postings from December 2002

Re: using \n in a cgi script

Thread Previous | Thread Next
From:
R. Joseph Newton
Date:
December 31, 2002 15:22
Subject:
Re: using \n in a cgi script
Message ID:
3E12270B.F3499847@efn.org
Hi,

Look at your source for the web page.  You will see:
<H1>Salut\&nbsp;!</H1>
Bienvenue dans notre magasin d'habillement\&nbsp;
Faites votre choix dans le menu ci-dessous

Which will show up in your browser as:    #apologies to those without HTML-enabled  mail clients
Salut
Bienvenue dans notre magasin d'habillement Faites votre choix dans le menu ci-dessous

Which is exactly what you told the browser on the other end to do:  Display twoo space in headline font, then add the "Bienvenue...d'habillement" one space [&nbsp;], and then the "Faites ... ci-dessous" on the same l;ine.

My suggestion:  write your desired web page first in NotePad, SimpleText, or some other plain-text browser.  Save it with an HTML extension, then test it by opening it in a browser.  Once you can generate the source by hand, you will then simply have to send that source, putting an \n at the end of each line you want to show up in your source code.  Any time you need a line-break to show up in the browser, you will have to use either an end-paragraph or headline: </p> /h1> </h2>, etc; or use an explicit break <br> tag.

Joseph

dhoubrechts wrote:

> Every time I want to use a perl script as a cgi the "\n" ending the
> phrases doesn't make it going at the beginning of the next line. Why ?
> Several script coming from Perl in Action (O'Reilly) have those "\n"
> ending those phrases.
> Here are some lines coming from one of them :
> sub document_de_garde {
>     my $actif = shift;
>     return unless $actif;
>
>     print "<H1>Salut\&nbsp;!</H1>\n";
>     print "Bienvenue dans notre magasin d'habillement\&nbsp;!\n";
>     print "Faites votre choix dans le menu ci-dessous.\n";
>
>     menu_boutique();}
>
> If I want to use them a have to change using print p(...); ?
> Thanks for response.
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About