Re: goto return ?
- From: mumia.w.18.spam+nospam@xxxxxxxxxxxxx (Mumia W.)
- Date: Fri, 24 Nov 2006 23:51:20 -0600
On 11/24/2006 05:37 PM, JupiterHost.Net wrote:
Tom Phoenix wrote:On 11/24/06, JupiterHost.Net <mlists@xxxxxxxxxxxxxxx> wrote:
The trick is I can't seem to goto() return in
do_some_stuff_and_return(), I'm sure since its so deep down...
Are you saying that you want a subroutine that can make the subroutine
that called *it* return? I'm not sure that that would make sense; and
it's not something that anybody's style guide recommends for normal
programming, since it leads to some ambiguous situations.
There's probably a better way to structure your algorithm. Or maybe
I've misunderstood your situation. Good luck with it!
Thanks Tom, I'll try to clarify.
In a function I can do this:
# stuff here
if($whatever, @ret) {
one();
two();
goto &CORE::return; # this is pseudo code that does not work but illustrates the idea of the goal
}
# keep going since that function didn't return.
Say you have to do that expect same logic ten times, it'd be nice instead of fifty of the exact same lines to have ten lines by do ing this:
# stuff here
do_one_then_two_then_return_if($whatever);
# keep going since that function didn't return.
Just need to figure you how to get the functionality that:
goto &CORE::return;
feels like it should do assuming I knew how to reference return...
What about doing this?
return if do_one_then_two($whatever);
....
sub do_one_then_two {
my $what = $_[0];
if ($what) {
one();
two();
return 1;
}
return 0;
}
Or you could use the (much to complicated for this) Error module.
.
- Follow-Ups:
- Re: goto return ?
- From: JupiterHost.Net
- Re: goto return ?
- References:
- goto return ?
- From: JupiterHost.Net
- Re: goto return ?
- From: Tom Phoenix
- Re: goto return ?
- From: JupiterHost.Net
- goto return ?
- Prev by Date: Re: Why this error ?
- Next by Date: Re: goto return ?
- Previous by thread: Re: goto return ?
- Next by thread: Re: goto return ?
- Index(es):
Relevant Pages
|