I have written a Perl script to read the configuration file and create CGI scripts. This works fine and I get the output of CGI script on terminal and I can execute that CGI scripts on web pages. Below is my sample script.
#!/usr/bin/perl -w
use strict;
use Text::Template;
my $conf = "test.cfg";
open CFG, $conf or die "Could not open config file";
my @rawConfig = <CFG>;
my $config = eval "{".join("",@rawConfig)."}";
my $template = Text::Template->new(TYPE => 'FILE', SOURCE => 'test.cgi.tmpl');
my $result = $template->fill_in(HASH => $config);
print $result;
By using this I have to save each of the CGI and execute separately. I need help to modify this code so that I can directly execute this script on web and display the output on webpage.
Multiple template based scripts is (almost) never the right answer.
Use data structures from a config file and control structures to get the behaviors you need.
Instead of using a template to create code like:
Do this:
You can bind config info to a subroutine (that is ‘curry your functions’) by generating closures with config info: