in reply to Re^2: Return value from code reference stored in dispatch table
in thread Return value from code reference stored in dispatch table
I do not have to do the explicit setting of $RtnVal (since it is set in the subs)... [emphasis added]
This implies that $RtnVal is a global. Along with hdb, I'm handicapped by not having an example of the referenced code, e.g., emailagenda(), but are you aware that a subroutine, named or otherwise, that does not have an explicit return statement implicitly returns the value of the last expression evaluated within the subroutine? A situation something like the one described in the OP can be imagined via this scenario:
>perl -wMstrict -le "our $RtnVal; our $SomeOtherGlobal; ;; my $coderef = sub { $RtnVal = $_[0]; if ($RtnVal eq 'Ok') { $SomeOtherGlobal = 'Foo'; } }; ;; for my $arg (qw(Ok NotOk)) { $RtnVal = $coderef->($arg); print qq{RtnVal '$RtnVal'}; } ;; for my $arg (qw(Ok NotOk)) { $coderef->($arg); print qq{RtnVal '$RtnVal'}; } " RtnVal 'Foo' RtnVal '' RtnVal 'Ok' RtnVal 'NotOk'
|
|---|