?
Solved

Perl include output

Posted on 2000-04-08
4
Medium Priority
?
228 Views
Last Modified: 2013-12-25
I have ASP pages that load in standard headers & footers using the following:

<!--#include virtual="/headers/header.inc" -->


Now I have 1 perl script (someone gave me) that I want to include the same headers and footers as I do in my ASP page.

The current static code the perl script generates is:
print "<HEAD>\n";
print "\t<TITLE>Telephone Directories Search Results</TITLE>\n";
print "</HEAD>\n\n";

What do I need to do to output the code from the above include  file (after the title)?

Thanks!
David
0
Comment
Question by:david_levine
[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
4 Comments
 

Expert Comment

by:akf
ID: 2696627
# Here's one way. Note that if it fails to open the include file,
# it will put a comment in your HTML saying why -- so look at the source
# if you don't see your file.
#
# You'll need to include the full path to header.inc.

my $incfile = "/fullpath/headers/header.inc";  # EDIT PATH
open (INFILE, "<$incfile") || print "<!-- couldn't open $incfile: $! -->\n" ;
                   
my $buf;
 
  { local ($/) = undef ;   # slurp entire file (not one line at a time)
     $buf = <INFILE>;
  }

close INFILE;

print $buf;


0
 
LVL 84

Accepted Solution

by:
ozo earned 300 total points
ID: 2697273
#you can also just
print <INFILE>;
#to slurp entire file and print it without having to set $/
#but it may be more efficient to print it one line at a time:
print while( <INFILE> );
#so you don't need to load the entire file into memory before you can start printing
0
 
LVL 9

Author Comment

by:david_levine
ID: 2697602
Thanks to the both of you!

I've adjusted the points from 75 down to 50 and will give the 50 to akf and post another question in this section for ozo for an additional 50.

Thanks again
0
 
LVL 9

Author Comment

by:david_levine
ID: 2697603
Oops... clicked the wrong button! :(

akf... I'll post your points as a new question in this section.
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
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.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

777 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