View Full Version : perl with css
jskam
July 15th, 2004, 01:02
Hi guys
actually i am beginning to learn and write perl scripts, and while writing one of my perl script with css, the following happned
My code:-
#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
use warnings;
use CGI;
$query = new CGI;
print $query->header;
print "<html>\n<head>\n<title>Testing css with perl v0.03</title>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"testcss2.css\"></head>\n";
print "<body>\n";
print "<h2>TESTING css with perl</h2>\n";
print "</body>\n</html>";
testcss2.css
h2 { color:orange; font-style:italic }
Now the problem is that, when i run this script, the css effects are not shown to the text "TESTING css with perl"..and the text "TESTING css with perl", displayed is plain, without showing any css effects....
whereas i want the css effects to be displayed...
how shall i do this?
Can somebody please help me here!
Thanks!
atlas
July 20th, 2004, 14:36
Based on your code there, you'd have to put "testcss2.css" in the same directory as your script. testcss2.css will be loaded by the client browser, not by perl.
jskam
July 21st, 2004, 00:26
testcss2.css is already in the same directory as the script!
testcss2.css will be loaded by the client browser, not by perl.
how???can you modify the code and help me??
GregT
July 21st, 2004, 03:39
First off, use heredocs so it's actually readable.
#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
use strict;
use warnings;
# No need to import CGI just to print a simple Content-Type.
print "Content-Type: text/html\n\n\n";
print <<HTML;
<html>
<head>
<title>Testing CSS with Perl</title>
<link rel="stylesheet" type="text/css" href="testcss2.css"/>
</head>
<body>
<h2>Testing CSS with Perl~</h2>
</body>
</html>
HTML
__END__
And your CSS file should look like this:
h2 {
color: orange;
font-style: italic;
}
Final Result: http://www.yupadog.com/demo/script.pl
jskam
July 21st, 2004, 04:21
well, thanks for the reply there, but it still doesnt work, and the amzing thing is that i just copy pasted your code!, but it still doesnt work
my url
http://jsk1.netfirms.com/cgi-bin/testcss-wperl.pl
code:- testcss-wperl.pl
#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
use warnings;
use strict;
# No need to import CGI just to print a simple Content-Type.
print "Content-Type: text/html\n\n\n";
print <<HTML;
<html>
<head>
<title>Testing CSS with Perl</title>
<link rel="stylesheet" type="text/css" href="testcss2.css"/>
</head>
<body>
<h2>Testing CSS with Perl~</h2>
</body>
</html>
HTML
__END__
testcss2.css code
h2 {
color: orange;
font-style: italic;
}
IT STILL DOESNT WORK!!
GregT
July 21st, 2004, 06:15
I'm thinking it has to do with your host.
Ask somebody on their support forum/help desk what's up with it.
jskam
July 22nd, 2004, 05:20
I'm thinking it has to do with your host.
Ask somebody on their support forum/help desk what's up with it.
actually i tried the script, on several hosts and not one...everywhere its the same..
Well can you send me the exact source code of your file http://www.yupadog.com/demo/script.pl
, then i will just upload that and run it, and see whether it works or not?
my email is jskam1@gmail.com or you can pm me also...whichever you prefer
Thanks!
GregT
July 22nd, 2004, 05:27
I just renamed it to .plsource so you can see the code.
http://www.yupadog.com/demo/script.plsource
jskam
July 23rd, 2004, 05:01
I just renamed it to .plsource so you can see the code.
http://www.yupadog.com/demo/script.plsource
i still cant see the code, i can see only partial code,
wait let me show you
http://jsk1.netfirms.com/testscreenshot2.jpg
GregT
July 23rd, 2004, 06:00
Do you have any other browser other than IE?
Use something like Firefox or wget to view/download it.
atlas
July 23rd, 2004, 08:00
i still cant see the code, i can see only partial code,
wait let me show you
http://jsk1.netfirms.com/testscreenshot2.jpg
Just do a "View Source" on that page to get the code.
Something else to verify is that you can download testcss2.css in your browser. Hosts will sometimes not allow non-executable files to be served from a cgi-bin.
-mk
jskam
July 23rd, 2004, 19:46
Do you have any other browser other than IE?
Use something like Firefox or wget to view/download it.
no, i dont, but i am able to view the exact code, thru view->source
Something else to verify is that you can download testcss2.css in your browser. Hosts will sometimes not allow non-executable files to be served from a cgi-bin.
i am not able to download, testcss2.css, via the browser, and i am getting a 403 forbidden error.
What chmod shall i put on testcss2.css, so that it can be accesed by my original file testcss-wperl.pl ??
GregT
July 24th, 2004, 00:16
Try to chmod it to 0666.
If that doesn't work, you can always put the CSS file outside of the cgi-bin and just change the link to it.
jskam
July 24th, 2004, 00:42
changing it to 666 didnt help much
but then i transfered the css file to directory other than cgi-bin, and it worked....
Thanks greg and atlas, for the help!
Powered by vBulletin® Version 4.1.7 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.