in reply to Re^2: Closures and undefined subs
in thread Closures and undefined subs

Just to make it more clear:
Status quo:
use Math::RungeKutta; sub outer { my $var = sub_from_other_package(); no warnings qw(closure); sub differ { my $y = shift; $var->[...]{...}{...}; etc. ... return $res; } sub dydt { my ($t,@y) = @_; return differ($y); }; ($t, @y) = rkXXX(\@y, \&dydt, $t, $dt); }
Neither local nor subs declared in lexicals help me out of my misery. The former is undefined the next is used as ""-ref. So There is a bug but what could it be that turns a sub into undefined?
Hope you still with me and not bored ;)

Replies are listed 'Best First'.
Re^4: Closures and undefined subs
by ikegami (Patriarch) on Sep 26, 2007 at 16:13 UTC
    use Math::RungeKutta; sub outer { my $var = sub_from_other_package(); my $differ = sub { my $y = shift; $var->[...]{...}{...}; etc. ... return $res; }; my $dydt = sub { my ($t,@y) = @_; return $differ->($y); }; ($t, @y) = rkXXX(\@y, $dydt, $t, $dt); }
    • Removed no warnings qw(closure);.
    • Converted each named sub to an anon sub.
      • Don't forget the semi-colon at the end of the block. sub is like a function when there's no name.
    • Changed \&dydt.
      Will try it out tomorrow. Original code of the whole module (but it needs other 3 not posted and the original main programme) was posted as answer for your demand for original code a bit earlier.

        I didn't ask for the original code. Quite the opposite. I asked for the code giving the error. What you posted doesn't demonstrate the problem, so its useless. We can't debug code we don't see.