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

That's the original code still!! We have already told you how to fix it, and it does not give the errors you want us to look at.

However, I think I guessed what you are doing wrong: setting local *func or my $func after the point where it's used.

# BAD sub outer { my $var; ($t, @y) = rkXXX(\@y, $dydt, $t, $dt); my $dydt = sub { ... }; } # Good sub outer { my $var; my $dydt = sub { ... }; ($t, @y) = rkXXX(\@y, $dydt, $t, $dt); }

Replies are listed 'Best First'.
Re^9: Closures and undefined subs
by KaiAllard_ (Initiate) on Sep 26, 2007 at 20:42 UTC
    I dont have all the code here but I am almost sure you are absolutely right...
    Thats why it tolds me in any case undefined or empty reference...
    I was not aware that I am changing semantic of "anywhere" sub to "define before use" variable with local!

    Will try it out but I guess you solved my problem.

      I was not aware that I am changing semantic of "anywhere" sub to "define before use" variable with local!

      There's nothing magical about the = in local *func = sub { ... }; or my $func = sub { ... };. It's an assignment like any other. You can't fetch the value from a variable before you assign the value to the variable. Or as the case is here, before you even create the variable.