Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

calling CSS file inside perl code

calling CSS file inside perl code

calling CSS file inside perl code

can i call Cascading style sheet inside a perl script?
Is there any way to bring style sheet concept inside perl?

RE: calling CSS file inside perl code

there is formatting for perl.. lots and lots of it... if you are referring to how it prints stuff.


RE: calling CSS file inside perl code

If you are referring to just using a CSS document for some HTML that you print out with Perl, all you would have to do it the following:


print "Content-type:text/html\n\n";
print "<html><head><title>this is the title</title>\n";
print "<style>\n";
print "a {color:black}\n";
print "a.hover {color:white}\n";
print "</style></head><body>\n";
print "</body></html>\n";

Is that what you were referring to?

Hope this helps,


vic cherubini
Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director

RE: calling CSS file inside perl code

hi vikter,
The code u have given is to write the css inside perl. But what i m expecting is how will u call a external css file inside a perl code?

RE: calling CSS file inside perl code


print "<style>\n";
open(FILE, "stylesheet.css");
   print "$_\n";
print "</style>\n";


RE: calling CSS file inside perl code

will it do the formatting with html code?

RE: calling CSS file inside perl code

it will format the code when it is printed to the browser... the browser handles these things... perl just makes the output.


RE: calling CSS file inside perl code

If you have HTML tags in the Perl script that are outputting to a browser, you can call an external CSS file just as you would with a plain HTML file. Just don't forget to escape any quotes or it will crash. You may or may not need to use "print" depending upon how your HTML section it written. In some, I can do it this way:

print "<link rel=stylesheet href=\"style.css\" type=\"text/css\">\n";

While in others, a plain HTML tag will do:

<link rel=stylesheet href="style.css" type="text/css">

The style sheet may need to be located somewhere other than your cgi-bin, in which case, you will need a full or relative path to it.

Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT (only when I have to!)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close