Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Should be easy: Including text

Posted on 1998-07-23
3
Medium Priority
?
166 Views
Last Modified: 2013-11-18
I'm using a perl CGI script to create an HTML page based on certain conditions.

I would like to include text from other files (sort of like a server side include), but I can't seem to do this within the cgi script.

What I'd like to do is almost like a "Location:" redirection, but instead it would just include the text in the specified file rather than redirect the browser to the new url. Then I could also include text from one or two other files, depending on the circumstances.
0
Comment
Question by:csi
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
b2pi earned 200 total points
ID: 1208712
print "Content-type: text/html\n\n";

if (Condition 1) {
   &PFile("File to use if condition1 is true") || handle an error message here.
}

if (Condition 2) {
  &PFile("File to use if condition 2 is true") || handle an error here.
}
 ....


sub PFile ($) {
   my($file) = shift;
   open(F, "<$file") || return 0;
   while (<F>) {
     print;
  }
  close(F);
}
0
 

Author Comment

by:csi
ID: 1208713
Jeez! I thought this was going to be easy. I'll have to try this out.
0
 

Author Comment

by:csi
ID: 1208714
Perfect! Thanks.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question