D
dan
hi,
Firstly, I'm not sure if this post is about callbacks, but here goes.
I have two modules, in moduleA I have
$self->{_coderef} = undef; # and later on...
$self->{_coderef}->sayhello if defined $self->{_coderef};
moduleB contains the subroutine
sub sayhello {
print 'hello';
}
Now I can write a script that says
my $testA = new moduleA;
my $testB = new moduleB;
$testA->{_coderef} = $testB;
Now the code
$self->{_coderef}->sayhello if defined $self->{_coderef};
prints 'hello'.
OK so far so good, but now I wonder if there is a way I can change
moduleA so that it does not contain the string 'sayhello'. Instead the
script passes the subroutine name to moduleA. I have tried various things
but so far no luck.
Any ideas? Sorry no actual code.
dan
Firstly, I'm not sure if this post is about callbacks, but here goes.
I have two modules, in moduleA I have
$self->{_coderef} = undef; # and later on...
$self->{_coderef}->sayhello if defined $self->{_coderef};
moduleB contains the subroutine
sub sayhello {
print 'hello';
}
Now I can write a script that says
my $testA = new moduleA;
my $testB = new moduleB;
$testA->{_coderef} = $testB;
Now the code
$self->{_coderef}->sayhello if defined $self->{_coderef};
prints 'hello'.
OK so far so good, but now I wonder if there is a way I can change
moduleA so that it does not contain the string 'sayhello'. Instead the
script passes the subroutine name to moduleA. I have tried various things
but so far no luck.
Any ideas? Sorry no actual code.
dan