That might be a bit overkill for your situation, but you could solve your problem with continuation passing, something along these lines:
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 {
...
});