Solved

Perl include output

Posted on 2000-04-08
4
221 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
Comment Utility
# 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
Comment Utility
#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
Comment Utility
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
Comment Utility
Oops... clicked the wrong button! :(

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

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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 …
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
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…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now