in reply to Closures question

Strange. I just tried this:
sub doStuff { my $toggle = initToggle( 1 ); blah($toggle); } sub blah { my $t = shift; for ( 1..6 ) { print &$t . "\n" } }
and it worked just fine.

Are you doing something differently than the above? Are you storing your code ref as the key in a hash, then pulling it back out and trying to use it again? If so the ref will be stringified and thereafter useless as a code ref. In fact, any stringification of your reference will render it unusable.

Replies are listed 'Best First'.
RE: Re: Closures question
by cianoz (Friar) on Oct 20, 2000 at 01:40 UTC
    Ok but then "use strict" would report:
    can't use string ("CODE(_SOMETHING_)") as a subroutine ref while "strict refs" in use
      Well yes, of course. But just to clarify, I don't think Ovid actually gave us an error message in his original post. So he very well *could* have received such an error--who knows.