Gossamer Forum
Home : General : Perl Programming :

# as an ordinary character not a symbol of comment

Quote Reply
# as an ordinary character not a symbol of comment
Hello,

I need to use '#' as an ordinary character in my cgi script, not a symbol of comment. Can I do that?

The script includes some html code in which there's a SSI command ( <!--#include virtual...). I guess perl treats '#' before 'include' as a symbol of comment....so it doesn't work

Thanks,

Peter Pietrusza
Quote Reply
Re: [sealdeon] # as an ordinary character not a symbol of comment In reply to
No it doesn't treat it as a comment if you are trying to print it. The problem you are having is that you can't use SSI within a cgi script. SSI requires server parsing but perl scripts are parsed and compiled by perl.
Quote Reply
Re: [Paul] # as an ordinary character not a symbol of comment In reply to
Well, the script doesn't print, but it generates some static html pages, so I just need to put <--#include... (with that #) into the generated files... is there any way to do that?

Peter
Quote Reply
Re: [sealdeon] # as an ordinary character not a symbol of comment In reply to
What code do you have so far?
Quote Reply
Re: [Paul] # as an ordinary character not a symbol of comment In reply to
It's Links 2.0 and the file is site_html.pl. There are templates for generated pages. It goes like this:

-cut-
[..]
sub site_html_home {

my ($output);

$output = qq~

<html>

<HEAD>

<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=iso-8859-2">

<title>$site_title</title>

</head>

<$site_body>


<!--#include virtual=menu_lewa" -->

[..]

~;

return $output;

}

-cut-

Quote Reply
Re: [sealdeon] # as an ordinary character not a symbol of comment In reply to
Hmm then it looks like post 2 still applies.

You can't execute SSI commands from within a cgi/pl script.
Quote Reply
Re: [sealdeon] # as an ordinary character not a symbol of comment In reply to
Have you looked into CGI::SSI?

http://search.cpan.org/.../CGI-SSI-0.53/SSI.pm

Code:
NAME

CGI::SSI - Use SSI from CGI scripts

Does what it says on the tin.

- wil
Quote Reply
Re: [Paul] # as an ordinary character not a symbol of comment In reply to
I don't want to execute that <!--#include.... . I just would like to put it into a .html file that is generated by cgi script. So SSI wouldn't be executed from cgi file, but from .html...
Quote Reply
Re: [sealdeon] # as an ordinary character not a symbol of comment In reply to
Quote:
I just would like to put it into a .html file that is generated by cgi script. So SSI wouldn't be executed from cgi file, but from .html...

No, your html is inside a perl print qq~ ~; statement so you are executing it from within your script. You can't do it like that, trust me =)

Last edited by:

Paul: Jun 20, 2003, 8:58 AM
Quote Reply
Re: [Paul] # as an ordinary character not a symbol of comment In reply to
Alright :-)

So what can I do to just put that line (<!--#include...) into a file generated by the script, so that ssi was executed from a normal html/shtml file, but not from the script file?

Or how to include something inside cgi file ? I know what the problem is, but I don't know the solution...

How can the link a couple of posts above be helpful ? :-) What should I do with it...

Forgive me all these questions, but I'm rather not a perl-master :-)