Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: The Power of Objects

by cees (Curate)
on Jul 28, 2005 at 14:33 UTC ( #478989=note: print w/ replies, xml ) Need Help??


in reply to The Power of Objects

If you would have used an OO framework like CGI::Application for the structure of your app, you would have been able to do this very easily, without needing to subclass HTML::Template.

package My::App; use base qw(CGI::Application); sub load_tmpl { my $self = shift; my $template = $self->SUPER::load_tmpl(@_); # add some global params here $template->param( ... ); return $template; } sub runmode { my $self = shift; my $template = $self->load_tmpl('filename.tmpl'); $template->param( ... ); return $template->output; }

OO doesn't work for everything, but if you find yourself passing the same bits of data to all of your functions, then you probably should at least investigate using an object instead.

Comment on Re: The Power of Objects
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (12)
As of 2016-04-29 16:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    :nehw tseb si esrever ni gnitirW







    Results (441 votes). Check out past polls.