in reply to scope of my $x in if statements

I would probably do this as (or as nested if's as ikegami suggested):

{ my $x; if( $x = f() and g($x) ) { ... } }

If you really didn't like the extra block/indent, you could also do:

{ last unless( my $x = f() ); last unless( g($x) ); ... }