[ back to toc ]

css import in a cgi generated page

Date: 2002/01/27 10:18

Q:
Peter,

I would like to know how to have a cgi script write a page that imports
(as opppsed to links)a css file. I am having trouble with the syntax. I
would like to call the file absolutely, ie:

<style type="text/css">
<!@import "http://www.mysite.com/myfile.css";
-->
</style>

The syntax I have tried only crashes the script.
Thanks so much for your help.

*NAME-DELETED*
A:
If the script is Perl and you print out these lines in a "here string"
construct like

print <<END;
<style type="text/css">
<!@import "http://www.mysite.com/myfile.css";
-->
</style>
END

then the array @import is evaluated inside the string by the Perl
interpreter and causes problem. Thus you have to write:

print <<END;
<style type="text/css">
<!\@import "http://www.mysite.com/myfile.css";
-->
</style>
END

putting a backslash before each @ character. (If you develop it further do
not forget to put \ before each $ character as well.)

You can also write:

print <<'END';
<style type="text/css">
<!@import "http://www.mysite.com/myfile.css";
-->
</style>
END

in which case the string is not interpolated.

Regards,
Peter

[ back to toc ]