in reply to Re^2: displaying html file in the browser using perl
in thread displaying html file in the browser using perl
Try without the x modifier on the regex
poj#!/usr/bin/perl use strict; use CGI; use File::Slurp qw/read_file/; my $includepath = "c:/temp/"; my $file_to_read = 'aa.html'; my $html = read_file($file_to_read); $html =~ s{<!--#include file="([^"]+)"-->} {&add_template($includepath.$1)}gei ; print CGI::header(); print $html; sub add_template{ my $file = shift; if (-e $file){ return read_file($file); } else { warn "$file not found"; return '<!-- $file not found to include -->'; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: displaying html file in the browser using perl
by tsdesai (Acolyte) on Dec 19, 2016 at 19:06 UTC | |
by poj (Abbot) on Dec 19, 2016 at 20:03 UTC | |
by tsdesai (Acolyte) on Dec 20, 2016 at 08:41 UTC | |
by Corion (Patriarch) on Dec 20, 2016 at 08:49 UTC | |
by tsdesai (Acolyte) on Dec 20, 2016 at 08:56 UTC | |
|