in reply to Re^9: displaying html file in the browser using perl
in thread displaying html file in the browser using perl
my perl code as test.p is as below<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>
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, Tuse 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 -->'; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^11: displaying html file in the browser using perl
by marto (Cardinal) on Dec 20, 2016 at 10:56 UTC | |
|
Re^11: displaying html file in the browser using perl
by Corion (Patriarch) on Dec 20, 2016 at 10:16 UTC | |
|
Re^11: displaying html file in the browser using perl
by tsdesai (Acolyte) on Dec 20, 2016 at 10:40 UTC | |
by FreeBeerReekingMonk (Deacon) on Dec 25, 2016 at 10:07 UTC |