Hi, Monks.
We have a problem.
We have a 2 package & 2 object & 1 script.
test.cgi
use strict;
use ConfigFile;
use TestClass;
my $conf = new ConfigFile;
my $object = new TestClass;
$object->test();
ConfigFile.pm
package ConfigFile;
sub new {
my $that=shift;
my $class=ref($that) || $that;
my $self={ Verbose => 1, RaiseErrors => 0};
bless $self, $class;
return $self;
}
sub get_conf {
my $self=shift;
my $param=shift;
my $result; # get result
return $result;
}
1;
TestClass.pm
package TestClass;
sub new {
my $that=shift;
my $class=ref($that) || $that;
my $self={ Verbose => 1, RaiseErrors => 0};
bless $self, $class;
return $self;
}
sub anything {
my $self=shift;
#
# Here we nave a get object $conf from a test.cgi script.
#
return;
}
1;
Problems:
We need a use object $conf in method anything from object TestClass. How we can do this?
we know a 2 variants:
1. $object = new TestClass (conf_obj => $conf);
2. $object->anything($conf);
But this structure don't make me happy. I want a something also.
SUPER ? ISA ? Please Help me.
P.S."I'm sorry for my English"
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.