amnesty_puppy has asked for the wisdom of the Perl Monks concerning the following question:

Not using the CGI module but using Perl with CGI on apache I'm trying to output some HTML with an external stylesheet, I seem to remember this not working for external .js' as well.
style.css
H1 { font: normal 10pt Arial; }
style.pl
#!/usr/bin/perl use CGI; print CGI->header; print <<'END' <HTML> <HEAD> <TITLE>Test Css</TITLE> <LINK REL=StyleSheet TYPE='text/css' HREF=style.css></LINK> </HEAD> <BODY> <H1>Not styled</H1> </BODY></HTML> END

It seems to try to execute the stylesheet and I don't know why. From apache error_log - readwrite permission on style.css gives permission denied to execute, execute permission gives Exec format error.
Thanks, Dom.

Replies are listed 'Best First'.
Re: perl and CGI - stylesheets
by geektron (Curate) on Feb 03, 2005 at 18:39 UTC
    more specifically, your style sheet and your program need to live in the same directory because of your  LINK declaration.

    move (or copy) your stylesheet into your cgi-bin (which is where i'm assuming your script lives), and your styles will work. alternately, use a standard location for your styles ( say,  WEBROOT/css/ and have your  LINK reference that common directory.

    the second approach will keep you from having to maintain multiple copies of the style sheet.

Re: perl and CGI - stylesheets
by amw1 (Friar) on Feb 03, 2005 at 18:09 UTC
    Does style.css live in a directory that apache is using as a script directory? If so apache will try and execute any file in that directory. Try putting style.css in your normal documents directory.
Re: perl and CGI - stylesheets
by friedo (Prior) on Feb 03, 2005 at 19:07 UTC
    The replies above are spot-on; the problem has nothing to do with Perl, it's that your stylesheet exists where Apache is expecting to find CGI scripts.

    Now that that's settled, if you're going to be using CSS, you should really be using valid XHTML. What you've got there is not even valid HTML3, and the XHTML standard has been around for four or five years now.

      Specifically, the doctype is missing.

      Also, in your styles you use the pt (point) unit. You should only use this unit for stylesheets intended for print media, not for general media (which ends up in a graphical browser for most users). Use other relative units.

Re: perl and CGI - stylesheets
by Fang (Pilgrim) on Feb 03, 2005 at 19:12 UTC
    As the other Monks already stated, this is a problem related to how Apache is configured, not to perl or mod_perl.

    So, you can move your file out of the way, so it's not in the dir (or in any subdir) you have set up Options ExecCGI in. Or you can add a rule like RemoveHandler .css to that very same directory. As I've personally never gotten that last one to work, you can, as a last resort, create a style directory and set it up with SetHandler none using a <Directory> or <Location> directive.