Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: Question about web trees, html paths, and HTML::Template

by nedals (Deacon)
on Apr 06, 2008 at 18:01 UTC ( [id://678665]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Question about web trees, html paths, and HTML::Template
in thread Question about web trees, html paths, and HTML::Template

What still works is to have all domains using the same Perl and templates so, for example, instead of upgrading a Perl script in each of the domains, I only change it in one place.

Think about using modules to control your script processing.

use strict; use CGI; use CommonModule; use HTML::Template; my $q = CGI->new(); my $module = CommonModule->new( form_data => $q; ); my %templ_hash = $module->process_data(); my $template = HTML::Template->new(filename="$path/file.tmpl"); $template->param(%templ_hash); print $q->header(); print $template->output(); exit;

This would be the basic form of your .cgi scripts in each domain which are unlikely to change. Now any edits you do in the module or template will be applied to each domain.

Replies are listed 'Best First'.
Re^4: Question about web trees, html paths, and HTML::Template
by bradcathey (Prior) on Apr 07, 2008 at 12:50 UTC

    I'd be curious to see what CommonModule looks like just so that I understand your example. Thanks.

    —Brad
    "The important work of moving the world forward does not wait to be done by perfect men." George Eliot
      This is just a rough example. Check out some of the tutorials on Modules
      package <path>::CommonModule; use strict; sub new { my $self = bless({}, shift); ## So you could parse a multiple-valued hash if needed for (my $i=0; $i<@_; $i+=2) { defined($_[($i + 1)]) || die("CommonModule called with odd number +of parameters"); $self->{$_[$i]} = $_[($i+1)]; } return $self; } sub process_data { my $self = shift; ## something similar to your current cgi script processing my $form_item = $self->{formdata}->param('formname'); # get the for +m data ... ... my %templ_hash = ( #just like you would create your template hash ... ); return %templ_hash; } 1; # Don't forget to add this.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://678665]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-25 14:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found