in reply to Re^7: displaying html file in the browser using perl
in thread displaying html file in the browser using perl
The above code prints the main file which is 1204.html and then also detects that there is an included file given in the if condition but just doesn't print it. Not sure why. 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'; #mainfile to read my $html =read_file($htmlfile); #path of the included file my $includepath="/var/www/html/xx/xxx/"; 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"; return read_file($display_file); } else { # warn "$display_file not found"; return '<!-- $display_file not found to include -->'; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^9: displaying html file in the browser using perl
by Corion (Patriarch) on Dec 20, 2016 at 09:21 UTC | |
by tsdesai (Acolyte) on Dec 20, 2016 at 10:00 UTC | |
by marto (Cardinal) on Dec 20, 2016 at 10:56 UTC | |
by Corion (Patriarch) on Dec 20, 2016 at 10:16 UTC | |
by tsdesai (Acolyte) on Dec 20, 2016 at 10:40 UTC | |
by FreeBeerReekingMonk (Deacon) on Dec 25, 2016 at 10:07 UTC | |
|
Re^9: displaying html file in the browser using perl
by huck (Prior) on Dec 20, 2016 at 09:23 UTC |