in reply to looking for a good idiom: return this if this is true

The examples given here seem massively overcomplicated. Try the following:
print testing(); sub testing { return $_ if $_ = rval0(); return $_ if $_ = rval1(); } sub rval1 { return 1; } sub rval0 { return 0; }

Replies are listed 'Best First'.
Re^2: looking for a good idiom: return this if this is true
by merlyn (Sage) on Mar 05, 2005 at 19:41 UTC
    Except that those clobber a regional $_, which may be needed for other things. I might as well use the predeclared $a or $b instead, with just about as much chance of collision.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.