in reply to scope of my $x in if statements

How about this readable alternative ? :
if( my $x = $_ = f() and g($_) ) {....}
and if you REALLY need to modify $x inside g():
if($_ = \(my $x = f()) and $$_ and g($$_) )
Update: While I agree with ikegami's assessment below that this is not good practice, I maintain that this IS a solution to the problem posted by the O.P.

     ..to maintain is to slowly feel your soul, sanity and sentience ebb away as you become one with the Evil.

Replies are listed 'Best First'.
Re^2: scope of my $x in if statements
by ikegami (Patriarch) on May 07, 2009 at 22:21 UTC
    Clobbering your caller's $_ is bad (even in everyday scenarios), so you need to add local. When you do, you end up with the same problem and nothing is solved.