D
Drago
I have a module which I would like to be able to create instances of a
class it knows nothing about. Is there a neat way short of an anonymous
subroutine, like this example:
use Foo;
use Bar;
# this works, but seems overly verbose
Bar->new(sub { Foo->new(@_) } );
I note that
$c = \&Foo;
print ref($c); # says CODE
but within my module, one cannot then say
$c->new(...);
So I am not sure what \&Foo is giving me (i.e. a code reference to
what?). So is there a better way than the way I did it in the first example?
class it knows nothing about. Is there a neat way short of an anonymous
subroutine, like this example:
use Foo;
use Bar;
# this works, but seems overly verbose
Bar->new(sub { Foo->new(@_) } );
I note that
$c = \&Foo;
print ref($c); # says CODE
but within my module, one cannot then say
$c->new(...);
So I am not sure what \&Foo is giving me (i.e. a code reference to
what?). So is there a better way than the way I did it in the first example?