Link to home
Start Free TrialLog in
Avatar of david_levine
david_levine

asked on

Perl include output

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
Avatar of akf
akf

# 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;


ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of david_levine

ASKER

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
Oops... clicked the wrong button! :(

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