Solved

Should be easy: Including text

Posted on 1998-07-23
3
161 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 50 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

751 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