Click to See Complete Forum and Search --> : Syntax Question


CyCo
10-13-2003, 10:38 AM
Below you will find an example that will output simple HTML. My question can be found at the bottom of the script.

#!/usr/bin/perl

use strict;
use CGI;

my $q = CGI->new();

print $q->header,
$q->start_html( -title => "Hello",
-style => "body { font-family:verdana, arial, helvetica; }
h2 { font-size:125%; }",
-onload => "alert('Thanx for running this example')" ),
$q->h2( "Hello, Web Developer Forums Members" ),
$q->p( "I'm having trouble with the correct syntax for adding the following line:" ),
$q->p( "<link href=\"./css/styles.css\" rel=\"stylesheet\" type=\"text/css\">" ),
$q->p( "I can't seem to recall...I've searched for the answer...but, no luck" ),
$q->p( $q->a({ -href => "mailto:webmaster\@cycocity.com",
-style => "text-decoration:none;",
-title => "webmaster\@cycocity.com" }, "CyCo" )),
$q->end_html;

# #
# What is the correct syntax for adding the line below to the above example? #
# #
# <link href="./css/styles.css" rel="stylesheet" type="text/css"> #
# #
# I've tried every combination I could think of. Basically, I'm trying to #
# incorporate a style sheet, instead of directly adding each style's #
# attribute in the head of the document. Using standard syntax is NOT an #
# issue, it's the "object-oriented" syntax that's throwing me. Can someone #
# please shed some light on this? #
# #
# Thanx!, #
# CyCo #
# #

Charles
10-13-2003, 11:48 AM
1) You shouldn't be using double quotes when single ones will do. If you don't want to be escaping apostrophys then use the q operator.

2) See http://forums.webdeveloper.com/newreply.php?s=&action=newreply&threadid=19192.

CyCo
10-13-2003, 11:56 AM
yes, on both points,... now any information on the syntax to insert the stylesheet line...?

Charles
10-13-2003, 12:02 PM
Sorry about that but my second point should have read...

2) See http://www.perldoc.com/perl5.8.0/lib/CGI.html#LIMITED-SUPPORT-FOR-CASCADING-STYLE-SHEETS.

CyCo
10-13-2003, 12:09 PM
Thank you!

fuwsdotnet
10-16-2003, 01:49 PM
if the values of your html attributes do not and you are sure of this do not contain spaces dont even bother with the quotes. theres no need
john