Spidy has asked for the wisdom of the Perl Monks concerning the following question:
Greetings, fellow monks.
I am currently working on a project that involves having a number of pages that all have the same basic 'frame':
#!/usr/bin/perl -w use DBI; use strict; use CGI; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); use HTML::Template; use HTML::Entities; use lib 'code'; use config; my $template = templates::loadTemplate('template'); my %T; my $innerTemplate; ## Security $CGI::DISABLE_UPLOADS = 1; # no uploads! $CGI::POST_MAX = 512*1024; # max 512k post my $q = new CGI; my $c; ## different stuff here ## Filling in the template here if($innerTemplate) { # load the template in, put it into %T. my $template = templates::loadTemplate('$innerTemplate'); $template->param($T{innerContent}) if $T{innerContent}; $T{content} = $template->output(); } print $q->header(); $template->param(%T); print $template->output();
...And the only thing that seems to differ from script-to-script is the area that says "different stuff here".
This has gotten me to wondering: is there a way that I could write my scripts so that I would only need to write my 'frame' once? The code for a specific script would then somehow just get included into the area it needed to be. Does anyone know if this is possible, and how I'd do it if it was?
Thanks,
Spidy
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Framing my scripts
by kyle (Abbot) on Jul 27, 2007 at 02:21 UTC | |
by Spidy (Chaplain) on Jul 27, 2007 at 02:41 UTC | |
by kyle (Abbot) on Jul 27, 2007 at 03:07 UTC | |
by pKai (Priest) on Jul 27, 2007 at 11:45 UTC | |
Re: Framing my scripts
by dsheroh (Monsignor) on Jul 27, 2007 at 02:15 UTC | |
Re: Framing my scripts
by grep (Monsignor) on Jul 26, 2007 at 23:24 UTC | |
Re: Framing my scripts
by Cody Pendant (Prior) on Jul 27, 2007 at 00:45 UTC |
Back to
Seekers of Perl Wisdom