in reply to how to write a modified return() call?

I wouldn't do it your intended way but do

my $start_with = another_value() or return mywarn("Could not get another value");
with
sub mywarn { warn $_ for @_; return; };

but if you're hell-bent on confusing people with your program flow, see Scope::Upper and/or Continuation::Escape, which allow you to "skip" levels as you return up the call chain.

Replies are listed 'Best First'.
Re^2: how to write a modified return() call?
by leocharre (Priest) on Jul 14, 2009 at 19:03 UTC

    You know, that just pointed out the obvious to me. If I had this working properly.. It's not really perl anymore, is it.

    We can look at somebody else's code, a subroutine, and we can have a good idea of where something returns. It seems the only safe way to do this would be to very explicitly name the function, something like warn_and_return_undef()- which kinda would beat the purpose of brevity- much better to actually warn and return undef.

    I think this is what Fred P Brooks in the mythical man month (?) talks about in relation to sharpening tools that sharpen tools. A vicious programmer vice.