perlquestion
larryk
Maybe I'm just having an attack of premature senile dementia, but looking at the [cpan://DB] module [perldoc://DB|documentation] it looks like subclassing should be easy - something along the lines of:
<code>
package Devel::larryk;
use base qw(DB);
use strict;
Devel::larryk->new()->register(); # create instance and register
sub new { bless {} }
sub init {
my $self = shift;
$self->ready();
print "larryk initialised\n";
}
1;
</code>
This should then be invokable from the command line, as:
<code>
perl -d:larryk foo.pl
</code>
...but it doesn't work. Why?
<p>
Because as soon as I [perldoc://use] the DB module (in order to subclass it) it immediately calls ->init() on all registered clients. But of course I haven't registered as a client yet because I only just used it. So I seem to have a chicken and egg situation.
<p>
How can this work?
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-66604">
<pre><font color=#b0c4de size=2><a href="/index.pl?node=larryk"> larryk </a>
perl -le "s,,reverse killer,e,y,rifle,lycra,,print"
</font></pre>
</div></div>