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

Perl include output

Posted on 2000-04-08
4
224 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
  • 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 75 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
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…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

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