Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: \n won't work?!

by thezip (Vicar)
on Dec 29, 2002 at 08:58 UTC ( #222888=note: print w/replies, xml ) Need Help??

in reply to \n won't work?!

There is another clarification that can be made. While browsers will visibly collapse multi-white-spaces, you can do a "View Source" within the browser to see the raw (unrendered) HTML. From here you will see exactly what Perl has generated. For example, this script:
#!/perl/bin/perl -w use strict; use CGI; my $q = new CGI; print $q->header(); print qq(<!--prints "Hello World" with two embedded newlines-->\n); print qq(<b>Hello\n\nWorld</b>\n);
... will render:

Hello World

in the browser. "View Source" reveals:
<!--prints "Hello World" with two embedded newlines--> <b>Hello World</b>
By judiciously using newlines and HTML comments, you can document and beautify the raw HTML source so that troubleshooting is a snap.

I hope this helps.

Where do you want *them* to go today?

Replies are listed 'Best First'.
Re: Re: \n won't work?!
by Trimbach (Curate) on Dec 30, 2002 at 04:25 UTC
    If beautifying your HTML source is your goal, don't worry about adding \n's to your output... just slap a
    use CGI::Pretty;
    at the top of your program and let the CGI::Pretty module automagically do it for you. Laziness is a virtue. :-)

    Gary Blackburn
    Trained Killer

Re: Re: \n won't work?!
by Anonymous Monk on Dec 29, 2002 at 19:40 UTC
    How can I learn about all the different subroutines that are included in

    Thanks :)

      The best place to start would be perldoc CGI.

      --- print map { my ($m)=1<<hex($_)&11?' ':''; $m.=substr('AHJPacehklnorstu',hex($_),1) } split //,'2fde0abe76c36c914586c';

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://222888]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2021-12-07 19:23 GMT
Find Nodes?
    Voting Booth?
    R or B?

    Results (34 votes). Check out past polls.