> Hello all, Here is a question that may boggle some, including me. I am
trying to create a website that uses the same header and footer for all the
pages. This is not difficult when I am useing ASPs, I just use the #include
statement. However, whenever I want to add text generated by a perl script I
run into a problem. Whenever I embed perl into the asp's, the perl script
gets executed first, and then the #includes afterwords. By this I mean
##This is not real code, just an example to get my point across #Contains
#Contains will generate hello not too nice :( I was thinking that maby I
could use perl to read in the file header.asp and footer.asp and print out
the code accordingly, but I think that this may be cumbersom. I would really
like to get away from the ASP approach totally so that I can use perl
instead of perlscript. I was looking at perl's version of SSI, however I do
not think that this is what I want.... Any suggestions? Eric

Several suggestions:
The nearest perl equivalent of #include is probably do.  If you say
do "y.pl";
the contents of y.pl are executed at that point (similar to doing eval on
the contents of the file).  This is not exactly a text insertion: the stuff
in the file you do needs to be at least a valid perl expression.  For
example, here's y.pl:
"this is a header"

You can then say
print do "y.pl";
and it will print out the header.

Or, put the stuff you want to include into a package or module.  But this
too is not exactly #include, since it is not just insertion of text.
However, you can certainly declare your header and footer there.  For
example, here's header.pm:
#!perl -w
use strict;
package header;
our $text = "this is a header";
1;
__END__

In your main program, you can say:
use header;
print $header::text;

or whatever you want to do with it.

I'm not sure what you mean about perl and perlscript, though.  perlscript is
just perl.  Do you mean you want to write a CGI instead of an ASP?

--
Ken Bandes


_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to