http://www.perlmonks.org?node_id=129888


in reply to Would you use 'goto' here?

Considering that one of your objectives is to control what caller() reports then I think that using goto &sub is prefectly legitimate, after all that was the very reason why it is included in the language at all.

However to address the readability/maintainability of your code I think that perhaps you are taking the wrong approach, a slight change in methodology would IMO make it much more clear. Instead of having one sub that handles both the forwarding and the processing of one case, use one sub that forwards to two others. Give it a nice convienient, obvious name and presto, you get the magic with the readability:

sub edit_product_disptacher { # uses magic goto to fool caller() my ($query)=@_; if ( $query->param( 'officeID' ) ) { goto &edit_office_product } else { goto &edit_product } }
It seems to me that documenting that you are using a magic goto and why should be sufficient for and support programmer. It tells them what you are doing (so they can easily find the docmentation) and why, and once they read the docs they will (er, should :-) understand perfectly whats going on.

Yves / DeMerphq
--
This space for rent.