in reply to goto with some arguments

Personally, I think it is far from beautiful, it is also far from obvious what you are trying to do, try this:

if($this_is_not_right) { @_ = (error_code => 123, error_msg => 'this is error'); goto &somewhere; } do_something(); return; sub somewhere { my(%params) = @_; show_error_page($params{error_code},$params{error_msg}); }

We're not surrounded, we're in a target-rich environment!

Replies are listed 'Best First'.
Re: Re: goto with some arguments
by cfreak (Chaplain) on Mar 17, 2003 at 14:10 UTC

    Why do you need the goto?

    &somewhere; is going to do the exact same thing. Personally I agree with derby's comment down the page. The sub somewhere() isn't really needed at all, and the goto is completely pointless IMHO. Pass the parameters directly to your error handler.

    Don't get me wrong, there are legitimate uses for goto such as in AUTOLOAD. I just don't believe this is a legitimate use.

    Lobster Aliens Are attacking the world!