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

Re: using \n in a cgi script

Thread Previous | Thread Next
R. Joseph Newton
December 31, 2002 15:22
Re: using \n in a cgi script
Message ID:

Look at your source for the web page.  You will see:
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
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.


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:
> For additional commands, e-mail:

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About