Martin Moss wrote:
> Ah, that's what I'd thought to do, however I think I've 
> missed a step. I want to hide the subroutine referencing
> code from the user thus I want to do something like this:-
> 
> 
> my $Papp = new iBus::Papp('debug' => 1, 'callback' => "::MySub", 'LogFile'
=> '/var/log/MyPappLog.log');
> 
> $Papp->Start;
> 
> sub MySub
> {
>       print "Hello world";   #:-)
> }
> 
> So what I want to be able to do is to take the '::MySub' 
> string and make a reference to that subroutine and then
> execute that reference.

That's called symbolic references and is considered evil :-).

You could probably do it with

    &{ $foo->{'callback'} }('foo', 25);

(or however you get at the options passed to 'new'), but it would be nicer
if you did something like this:

    my $Papp = new iBus::Papp(debug => 1, callback => \&MySub, LogFile =>
'/var/log/MyPapplog.log');

that is, use \&MySub rather than '::MySub'. (Another option, I suppose, is
'string eval'. This may or may not be worse than symbolic references.)

Cheers,
Philip
_______________________________________________
Perl-Unix-Users mailing list. To unsubscribe go to 
http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users

Reply via email to