On October 30, 2003 07:58 am, Clint Moore wrote:
> I swear that it is probably something that I am doing but I can't for
> the life of me figure out where I'm going wrong. I have some run_modes
> defined in a separate file and referenced like this:
>
> sub setup {
> my $self = shift;
> $self->run_modes(
> 'mode1' => 'Module::method(\$self)',
> 'mode2' => 'Module::method2(\$self)',
> );
> }
>
> In 5.6.0 this worked no problem. Now that I have upgraded to 5.8.x, I
> cannot get this to work for anything.
You probably also upgrade C::A at the same time. You probably were
getting this to work due to some accident of design where the older
versions of C::A used eval STRING to run the runmodes. Current
versions use eval EXPR because it's way faster.
This could be looked at as a regression in functionality, except that
what you're doing was never intended to work from what I can tell in
the docs.. So I'd like to think of this as a tightening of
functionality rather than a regression ;->
You'll probably want to do something like these:
$self->run_modes(
'mode1' => sub { Module::method1(@_); },
'mode2' => sub { Module::method2(@_); },
);
or
$self->run_modes(
'mode1' => \&Module::method1,
'mode2' => \&Module::method2,
);
Both of these are untested, but should give you enough of an idea to go
on with. The point is that you're supposed to pass in either the name
of a function inside your C::A-derived object, or a code ref. The
above two examples both use the code-ref idea - the first uses anon
code refs, the second uses named code refs.
I'm sure there's a way to get this to work with strings, too, but I've
not tried. For example, this might work, too:
$self->run_modes(
'mode1' => 'Module::method1',
'mode2' => 'Module::method2',
);
I prefer the code refs myself ;-)
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/suppressed/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.