Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Should be easy: Including text

Posted on 1998-07-23
3
Medium Priority
?
163 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

688 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