in reply to how to write a modified return() call?
sub resolve_value { my $start_with = another_value(); unless $start_with { warn "Could not get another value"; return; } my $continuation = shift; return $continuation->($start_with, @_); } # and here's how you use that code: sub foo { # do some work here resolve_value(sub { my $start_with = shift; # do the rest of the work here }) }
If you care about performance you could also tail-call into the sub:
goto &resolve_value(sub { ... });
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to write a modified return() call?
by j1n3l0 (Friar) on Jul 15, 2009 at 10:52 UTC |