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
Solved

Should be easy: Including text

Posted on 1998-07-23
3
159 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 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Suggested Solutions

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
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.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

839 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