in reply to smart solution
Presumably you are passing something like \$key to this function with the intent of setting it? Is this a necessity because of the calling code? (from the name, it appears to be some sort of callback). If a necessity, you might want to document that in your code or choose a variable name that lets the reader know that $key is a reference to something of interest to the caller, and not the value itself.
But if it is not a necessity, I would consider a more idiomatic (for Perl) way of getting the value assigned to $key back to the caller: just return the value you want to assign to the key and use an assignment in the calling code:$x=dispatch_closing(...).
The effect of $$key=undef as the final statement of each if is to make the subroutine return the value assigned to $$key anyway - Perl always returns the value of the last executed statement. If you mean to return undef, then just do it, return undef. The intent is much clearer.
if ( some condition ) { } elsif ( some other conditional ) { } elsif ( yet another conditional ) { } else { }
Best, beth
|
|---|