Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

CSS in perl/CGI scripts

Options
  • 14-06-2007 4:52pm
    #1
    Registered Users Posts: 304 ✭✭


    Hi,

    I reckon this should be in programming rather than web design, but it's a close one to call, so if the mods reckon this should be elsewhere, feel free to move it.

    So my question is:

    I have a perl script that churns out a web page. Not being any sort of web designer, it's all done using functions from the CGI.pm module - even for the various tags etc. (I figure that it means that if conventions change, all that needs to be done is to update the CGI module, and it sticks)

    However, I want to make the page use an external CSS file, so it can look purty. Looking at CPAN, I can't see much by way of documentation that says whether it's supported one way or the other.

    Basically I want to get the
    <LINK href="style.css" type=text/css rel=stylesheet>
    
    bit shoved into the header... but preferably using CGI's functions.

    I've googled and I can't really find anything one way or another. Any ideas?

    Thanks,
    Aoife


Comments

  • Registered Users Posts: 6,509 ✭✭✭daymobrew


    print header(), start_html( -title => 'Page Title', -style=>{-verbatim => '@import url("/path/to/stylesheet.css");',-src=>'/path/to/stylesheet.css'} );
    
    produces [HTML]<link rel="stylesheet" type="text/css" href="/path/to/stylesheet.css" />
    <style type="text/css">
    @import url("/path/to/stylesheet.css");
    </style>[/HTML] An example is in the POD documentation for the CGI module.


  • Registered Users Posts: 304 ✭✭PhantomBeaker


    That is perfect - thank you!

    I obviously still need to get the hang of perl documentation. :/

    So it turns out that I got it mostly right before, but I did the inordinately stupid thing of putting it in the header() call rather than the start_html() part.

    D'oh


Advertisement