In a message dated Thu, 4 Oct 2001 10:21:27 AM Eastern Daylight Time, 
[EMAIL PROTECTED] writes:

> when writing to a console, you simply use \n to move to the next line
> but using the same code in a browser I get everything on the same line.
> 
> is there a way that when writing to HTML, the \n gets converted to <br> or 
> do you have to explicitly print out every <br>?

You need to sort out the distinction between server-side and client-side processing.  
Always, always consider:

1. Where is my code running?
2. Where are my variables located?

Perl or ASP code (using JavaScript or VBSCript) are processing on the *server*.  
Whatever chugging and churning takes place, the end result is a... <drum roll>

HTML stream.

What you are sending to a client/browser is an HTML stream.  You aren't sending Perl 
script.  Your server used your Perl script to generate HTML dynamically.  The output 
of your Perl script (your print statements) is an HTML stream.  If YOU sat at a 
terminal and typed the tags and content in real time, deciding what to type 
dynamically, it would be exactly the same thing (if slower in performance :-) ).

If you prepared an HTML document by hand for a client's browser, you would put only 
HTML tags in it because that's what the browser can interpret.  With CGI, you're 
simply using a speedy and dynamic tool to generate that text file for you so you don't 
have to type everything out in real time for every page request from a client!

You never type \n in an HTML document.  OTOH, you do type carriage returns to make 
your text document readable.  That's what \n is, right?  No matter how many blank 
lines you type, the browser doesn't interpret them.  It understands <br>.  If you want 
the client to break a line a line, you must write that tag to your HTML stream.

This is a verbose response.  However, you will live with these concepts the entire 
time you develop and debug scripts:

1. Location of processing (server vs. client)
2. Location of variables (server vs. client)
3. Server output = HTML stream
4. Client input = HTML stream

Keep looking at that model the whole time you work.

Nelson

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to