Apologies, for not including the code for the html file. contents of 1204.html(the main file i am reading)
<HTML> <HEAD> <LINK REL=StyleSheet TYPE="text/css" HREF="pages.css" TITLE=Pages><TIT +LE>New Academic </TITLE> </HEAD> <BODY BACKGROUND="/ff/img/bg2.gif" BGPROPERTIES="FIXED" BGCOLOR="#FFFF +FF"> <!-- Start of banner --> <CENTER> <!-- End of Banner --> <CENTER> <!-- Start of Topic Table --> <TABLE WIDTH="100%" BORDER=0 CELLSPACING=10 CELLPADDING=10> <TR> <!-- Start of Left Column --> <TD VALIGN=TOP> <TABLE WIDTH=100 BORDER=0 CELLSPACING=0 CELLPADDING=0> <!--#include file="somefolder/cc.html" --> </TABLE> </TD> <!-- End of Left Column --> <!-- Start of Middle Column --> <!-- Start of Topic --> <TD WIDTH="100%" CLASS=topic VALIGN=TOP> <H2><FONT CLASS=cf>Announcements</FONT></H3> <H3>New Academic</H3> fffff test some test content <P><FONT SIZE=-1 COLOR="#000099"> </TD> <!-- End of Middle Column --> <!-- End of Topic --> <!-- Start Right Column --> <TD WIDTH=100 VALIGN=TOP> </TABLE> </TD> <!-- End of Right Column --> </TR> </TABLE> <!-- End of Topic Table --> </BODY> </html>
my perl code as test.p is as below
use strict; use warnings; use File::Slurp qw/read_file/; use CGI; print CGI::header(); my $htmlfile ='/var/www/html/xx/xxx/1204.html'; my $html =read_file($htmlfile); my $includepath="/var/www/html/xx/xxxx/somefolder/"; if ($html =~ s{#include file="([^"]+)"}{&add_template($1)}gei) { print "the file has include file"; print $html; } else { print "doesn't have"; print $html; } sub add_template{ my $file = shift; #print "$file"; my $display_file="$includepath$file"; # print $display_file; if (-e $display_file){ #print "$display_file"; $sfile= read_file($display_file); #tried to see if it pri +nts file and it does print print $sfile;# displaying the included file return read_file($display_file); } else { # warn "$display_file not found"; return '<!-- $display_file not found to include -->'; } }
I hope i have now covered everything that i have been using . I have tried to display the included file in the subroutine by adding the sfile and it does seem to print but not when i do return read file. I hope i am being clear. Really appreciate all your help. Many Thanks, T

In reply to Re^10: displaying html file in the browser using perl by tsdesai
in thread displaying html file in the browser using perl by tsdesai

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.