use strict; use warnings; use Monks::Foo::ReturnInModule; weAreOffToSeeTheWizard(); #### use strict; use warnings; { package EmeraldCity; sub CLICKS { 2 }; } my $SOME_CLASS='EmeraldCity'; sub clickTheRubyShoes { my ($aData) = @_; # uncommenting this line also makes the problem go away #print STDERR "value of \$SOME_CLASS: $SOME_CLASS\n"; my $crClick = sub { my $iWhereWellGo = $aData->[$SOME_CLASS->CLICKS]; }; $crClick->(); print STDERR "Back in Kansas!\n"; return 1; } sub weAreOffToSeeTheWizard { print STDERR "value of \$SOME_CLASS: $SOME_CLASS\n"; clickTheRubyShoes(['So far away','Closer','Home']); return 1; } # there is NO warning or complaint about this "return 1" even # though it is outside a sub. # # with return 1 uncommented, # calling weAreOffToSeeTheWizard() results in # value of $SOME_CLASS: EmeraldCity # can't call method "CLICKS" on an undefined value at XXX line 14 # # with it commented out, and doing plain 1; to return we get # value of $SOME_CLASS: EmeraldCity # Back in Kansas! return 1; #1;