CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
# and "

 



tamt
newbie

Jun 21, 2001, 5:47 PM

Post #1 of 2 (925 views)
# and " Can't Post

I editing a script that will output HTML.

How can I get the script to ignore " and # that I type and take them as text to output in HTML rather than part of the pl script.

I am trying to do something like this:

print "<BODY BGCOLOR="#FFFF00" TEXT="#FF0000" LINK="#0000FF" VLINK="#FF00FF">\n";

but the script is taking the "# as being th epl script



mhx
Enthusiast / Moderator

Jun 21, 2001, 8:51 PM

Post #2 of 2 (921 views)
Re: # and " [In reply to] Can't Post

Hi!

Check this out, it's called heredocs:

Code
print <<'END'; 
<BODY BGCOLOR="#FFFF00" TEXT="#FF0000" LINK="#0000FF" VLINK="#FF00FF">
END

You have to assure that there are no extra whitespaces before the terminating END. This solution is best suited if you have long text.
For short text (like this one) you can also use the quoting operator qq:

Code
print qq(<BODY BGCOLOR="#FFFF00" TEXT="#FF0000" LINK="#0000FF" VLINK="#FF00FF">\n);

There's another solution, but it's full of backslashes:

Code
print "<BODY BGCOLOR=\"#FFFF00\" TEXT=\"#FF0000\" LINK=\"#0000FF\" VLINK=\"#FF00FF\">\n";

Anyway, if your script should output HTML, you should think of using the CGI modules. If you don't know them, type perldoc CGI at your shell / command prompt.
Hope this helps.


-- Marcus


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives