You will be benefited from a Perl OO tutorial, here is one picked at random http://wwwacs.gantep.edu.tr/docs/perl-ebook/ch19.htm. There is also the official tutorial: perlootut
I assume you have read Re: Mass Class Confusion - Who calls what how?
To inherit from a class just use (after the package declaration):
use parent 'HTTP::Server::Simple::CGI';There is also something similar in HTTP::Server::Simple's documentation...
But do you want that? Or do you want to instantiate a HTTP::Server::Simple::CGI object in your server and then call its run() method via your own run() whenever needed like so:
sub new { my ($class, $params) = @_; $self = {server_simple_cgi => undef, ...}; bless $self => $class; $params = {} unless defined $params; $self->{$_} = $params->{$_} for keys %$params; if( ! defined $self->{server_simple_cgi} ){ $self->{server_simple_cgi} = HTTP::Server::Simple->new(); } ... } sub run { my ($self, $params) = @_; # do something with params # and then run the server, it must be a valid object by now $self->{server_simple_cgi}->run() }
In this way you keep total control of your server and allow callers to control it only via certain API calls you provide (like the above run()) which may do additional checks, filter out things, before calling the server's, "real" run(). Note that this IS NOT about security (e.g. who is allowed to call what). Because a caller could still call $self->{server_simple_cgi}->run() (there are ways to avoid that: Objects with Private Variables). I am talking about the clarity and simplicity of the API you are building.
bw, bliako
In reply to Re^3: Mass Class Confusion - Who calls what how?
by bliako
in thread Mass Class Confusion - Who calls what how?
by holandes777
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |